Link to home
Start Free TrialLog in
Avatar of nguln
nguln

asked on

reverse a list

how to reverse a list in Lisp apart of using it's buid-in function reverse????


thanks
Avatar of ozo
ozo
Flag of United States of America image

Is this a homework problem?
You probably want to use car cdr and cons
Avatar of swdld
swdld

please what is "list in lisp" ???
LISP is a functional programming language designed to use lists.  Lists are defined by brackets as so:
( "a" 2 "c")
and embedded as so:
("a" (1 "b") ("c" ("d")))

which is a list with three elements, where the second element is a list with two elements, and the third element is a list with two elements, the second of which is a list.  Actually, only result lists display like that.  To define a list, use the List function, like this:

(List "a" 2 "c")

where you want the list elements to be the atoms "a", 2, and "c".
ASKER CERTIFIED SOLUTION
Avatar of Rick_Townsend
Rick_Townsend

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
The solution is elegant, but I think EE rules are that we can't give actual homework answers, only answer questions and help with debugging your algorithm.