I need to change the elements of a simple (one-dimensional) list. I know that there is a built-in callback function, but I cannot use it for this.
Here is my attempt:
(defun LISTREVERSE (LISTR) (cond ((< (length LISTR) 2) LISTR) ; listr is 1 atom or smaller (t (cons (LISTREVERSE (cdr LISTR)) (car LISTR))) ; move first to the end ) )
The conclusion is pretty close, but it’s wrong.
[88]> (LISTREVERSE '(0 1 2 3)) ((((3) . 2) . 1) . 0)
So I tried using append instead of cons :
(t (append (LISTREVERSE (cdr LISTR)) (car LISTR)))
But this error turned out:
*** - APPEND: A proper list must not end with 2
Any help?
source share