Question

Let lst1 = '(a b c d e), lst2 = '(1 2 3 4 5). The...

Let lst1 = '(a b c d e), lst2 = '(1 2 3 4 5). The proc function takes a list as input and returns the middle element of the list. What will be the following expression evaluate to:

(append (cons (first lst1) '())

(cons (cdddr lst1) '())

(cons (proc lst1) '())

(cons (proc lst2) '())

(cons (fifth lst1) '())

   )

a.

'(a d e c 3 e)

b.

'(a d e c 3 d)

c.

'(a (d e) c 3 e)

d.

'(a (d e) c (3) d)

e.

'((a) (d e) (c) (3) (d))

Homework Answers

Answer #1

The answer is option c. '(a (d e) c 3 e)

;append function will append all the elements
;(cons (first lst1) '()) will return a (first element in lst1)
;(cons (proc lst1) '()) will return (d e) (since cdddr will exclude the first three element and returns the rest of the list)
;(cons (proc lst1) '()) will return c which is the middle element of lst1
;(cons (proc lst2) '()) will return 3 which is the middle element of lst2
;(cons (fifth lst1) '()) will return the 5th element in lst1 which is e
;so the final list of all these elements is (a (d e) c 3 e)
(append (cons (first lst1) '())
(cons (cdddr lst1) '())
(cons (proc lst1) '())
(cons (proc lst2) '())
(cons (fifth lst1) '())
)

Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
16. Exhibit 22-2 (1) (2) (3) (4) (5) Variable Input Total Variable Cost Total Fixed Cost...
16. Exhibit 22-2 (1) (2) (3) (4) (5) Variable Input Total Variable Cost Total Fixed Cost Output Marginal Cost 1 $30 $100 20 2 $60 $100 50 (A) 3 $90 $100 90 (B) 4 $120 $100 120 (C) 5 $150 $100 140 (D) Refer to Exhibit 22-2. Diminishing marginal returns set in with the addition of which unit of the variable input? a. the first b. the third c. the fourth d. the fifth e. the second
Let the population have N=7 units, with {(unit,value)} = {(A,-1),(B,+1),(C,-2),(D,+3),(E,-4),(F,+5),(G,-6)}. The design is as follows: first...
Let the population have N=7 units, with {(unit,value)} = {(A,-1),(B,+1),(C,-2),(D,+3),(E,-4),(F,+5),(G,-6)}. The design is as follows: first choose A or B at random; if A then choose from {C,D} at random, if B then choose from {E,F,G} at random. 1) Find the first-order inclusion probabilities (note that the sample size n is fixed at 2). Verify (show numerically for this example) that the Horvitz-Thompson estimator is unbiased for the population total. (Hint: find the probability of each sample and the value...
Let X = {1, 2, 3} and Y = {a, b, c, d, e}. (1) How...
Let X = {1, 2, 3} and Y = {a, b, c, d, e}. (1) How many functions f : X → Y are there? (2) How many injective functions f : X → Y are there? (3) What is a if (x + 2)10 = x 10 + · · · + ax7 + · · · + 512x + 1024?
Consider the following symbols and their frequencies: a:1, b:2, c:3, d:4, e:5, f:6 What is the...
Consider the following symbols and their frequencies: a:1, b:2, c:3, d:4, e:5, f:6 What is the amount of bits needed per character for a balanced tree encoding.
If the matrix A is 4×2, B is 3×4, C is 2×4, D is 4×3, and...
If the matrix A is 4×2, B is 3×4, C is 2×4, D is 4×3, and E is 2×5, what are the dimensions of the following expressions a) A^TD + CB^T b) (B + D^T ) A c) CA + CB^T
1. Let T = {(1, 2), (1, 3), (2, 5), (3, 6), (4, 7)}. T :...
1. Let T = {(1, 2), (1, 3), (2, 5), (3, 6), (4, 7)}. T : X -> Y. X = {1, 2, 3, 4}, Y = {1, 2, 3, 4, 5, 6, 7} a) Explain why T is or is not a function. b) What is the domain of T? c) What is the range of T? d) Explain why T is or is not one-to one?
Define variables as follows: a = 1; b= 2; c = 3; d = 4; e...
Define variables as follows: a = 1; b= 2; c = 3; d = 4; e = 5; f = 6; g = 7; h = 8; i = 9; j =10; Using Matlab operations (no hard-coding), perform the following operations (in order): 1a) Add one to the value of a, and store the result in a 1b) Cube b, add the value of c to this, and store the result in b 1c) Set c equal to the larger...
a = [-5, -3, 2] b = [1, -7, 9] c = [7, -2, -3] d...
a = [-5, -3, 2] b = [1, -7, 9] c = [7, -2, -3] d = [4, -1, -9, -3] e = [-2, -7, 5, -3] a. Find (d) (e) b. Find (3a) (7c) c. Find Pe --> d d. Find Pc --> a +2b ex. C = |x|(xy/xy) C = xy/|x| ex. P x --> y = Cux = C(xy/x) (1/|x|) (x) =( xy/yy)(y)
Let Let A = {a, e, g} and B = {c, d, e, f, g}. Let...
Let Let A = {a, e, g} and B = {c, d, e, f, g}. Let f : A → B and g : B → A be defined as follows: f = {(a, c), (e, e), (g, d)} g = {(c, a), (d, e), (e, e), (f, a), (g, g)} (a) Consider the composed function g ◦ f. (i) What is the domain of g ◦ f? What is its codomain? (ii) Find the function g ◦ f. (Find...
Let A = {1, 2, 3, 4, 5, 6}. In each of the following, give an...
Let A = {1, 2, 3, 4, 5, 6}. In each of the following, give an example of a function f: A -> A with the indicated properties, or explain why no such function exists. (a) f is bijective, but is not the identity function f(x) = x. (b) f is neither one-to-one nor onto. (c) f is one-to-one, but not onto. (d) f is onto, but not one-to-one.
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT