intel1397 wrote:What is the best way to write a LISP program that will produce a mirror image of a list.
intel1397 wrote:Do I use a function such as mirror_image?
smithzv wrote:This question seems to go under the category of "so easy it must be for homework or learning CL." As such, I'm guessing it is not productive to answer the question.
[list](defun mirror_image (L)
(if (eq (cdr L) nil)
(append (mirror_image (cdr L))
(list (car L)))))[/list]
[list](mirror_image '((a b) (c (d e))))[/list]
smithzv wrote:Perhaps some leading questions:
What have you tried?
This looks a little like reversing the order of the list to me. There is a function REVERSE, but it doesn't do exactly what you want. How is what that does different from what you want?
(reverse '((a b) (c (d e))))
(reverse '(c (d e)))
intel1397 wrote:I came to this forum to learn and discuss Lisp Programming of any dialect. Not to have my “easy” question ridiculed and mocked about. Now if there is such a category “so easy it must be for homework or learning CL.” point me in the direction so that I am able to get the help that I need other then some immature juvenile looking to distract a new learner of CLISP.
(defun mirror_image (L)
(if (atom L)
(reverse (mapcar 'mirror_image L))))
(mirror_image '((a b) (c (d e))))
Users browsing this forum: No registered users and 5 guests