Question: 5. (20 Points) Write a lisp function (dup n x) that returns a list containing n copies of x. (Hints: if or cond, and
5. (20 Points) Write a lisp function (dup n x) that returns a list containing n copies of x. (Hints: if or cond, and cons) > (dup 1 'x) (X) > (dup 0 'x) NIL > (dup 2 'x) (X X) > (dup 2 ((Q) (Q)) > (dup 0 (UALR)) NIL 1 (q)) > (dup 4 (UALR (XYZ))) ((UALR (XYZ)) (UALR (XYZ)) (UALR (XYZ)) (UALR (XYZ)))
Step by Step Solution
There are 3 Steps involved in it
Sure Heres a Lisp function called dup n x that returns a list containing n ... View full answer
Get step-by-step solutions from verified subject matter experts
