CLISP - Odwracanie prostej listy

Muszę odwrócić elementy prostej listy (jednego wymiaru). Wiem, że istnieje wbudowana funkcja odwrotna, ale nie mogę jej użyć do tego.

Oto moja próba:

<code>(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
    )
)
</code>

Wyjście dość blisko, ale jest źle.

<code>[88]> (LISTREVERSE '(0 1 2 3)) 
((((3) . 2) . 1) . 0)
</code>

Więc spróbowałem użyćappend zamiastcons:

<code>(t (append (LISTREVERSE (cdr LISTR)) (car LISTR)))
</code>

Ale dostałem ten błąd:

<code>*** - APPEND: A proper list must not end with 2
</code>

Jakaś pomoc?

questionAnswers(4)

yourAnswerToTheQuestion