Write a LISP function(down lst) that wraps parentheses around each top-level ele
ID: 669899 • Letter: W
Question
Write a LISP function(down lst) that wraps parentheses around each top-level element of lst like in the following example.
> (down '(1 2 3))
((1) (2) (3))
> (down '(an idea))
((AN) (IDEA))
> (down '((a) (good) (idea)))
(((A)) ((GOOD)) ((IDEA)))
> (down '(a (more (complicated)) idea))
((A) ((MORE (COMPLICATED))) (IDEA))
>
Explanation / Answer
(defun down(lst)
(mapcar #'(lambda(x) ((x))) lst)
(terpri)
)
write (down '(a b c))
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.