I am having trouble with some lisp code. This function is just supposed to reverse a basic list. I can only use primitives, which are defined as " defun, cond, cons, car, cdr, null, eq, listp, atom, symbolp, +, -‐ , <, >"
In the example of passing (1 2 3 4) I get back (((4 3) 2) 1)
(defun reverse2 (l)
(cond
((eq nil (cdr l)) (car l) )
(t (cons(reverse2 (cdr l)) (cons (car l) nil)))))
Please let me know how to improve this. This is NOT for homework, I'm just working on this as an exercise for my final tomorrow.