r coMp I r coMpa r co x 4 Heap e 2282 c Here ls l Egyptia l

r coMp I r coMpa r co x 4. Heap e 2282 c Here ls l Egyptia l In Jobs H l 3. Inser coMp: l E ENGR2 n course r Divide, Merges O users oncardia.ca 2/notes/COMP348 assignment 2 FALL 2016.pdf 3 of 8 Question# 6: 120+6 Marksl In this question assume: \"first car\" and \"rest cdr\" and Lis list of some items such as numbers. a) Analyze this code and explain what myfunction2 is doing? (defun my function2 (L) (if nu L) nil cons (first L) my function2 (rest L O Ask me anything 40 ENG 0:40 PM US 2016-11-22

Solution

Answer:

Code is provided already

Note: I cannot download the interpreter, hence I explained about the task

(defun myfunction2 (L)

     (if (null L)

     nil

     (cons (first L)(myfunction2 (rest L))

     )

              )

)

The function is having a list called as L which is holding the list of numbers, initially the function is defined and that holds the value L as list. It checks whether the list is having the elements or not, if the list null then returns the nil as output, if the list contains any values, first it concatenates the first elements or any values then the rest of the values are examined in the rest which holds the value

 r coMp I r coMpa r co x 4. Heap e 2282 c Here ls l Egyptia l In Jobs H l 3. Inser coMp: l E ENGR2 n course r Divide, Merges O users oncardia.ca 2/notes/COMP348

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site