You are on the right track, but your last two conditions have the same action, which should give an indication that one of them is not doing what it should. Indeed, the second condition, the listp
case, is not right, because when it's a list, you need to append the reverse of that list instead of the unmodified list. A possible solution:
(defun reverse (l)
(cond ((null? l) nil)
((listp (car l)) (append (reverse (cdr l))
(list (reverse (car l)))))
(t
(append (reverse (cdr l))
(list (car l))))))
> (reverse '((1 2 3) (4 5 6)))
((6 5 4) (3 2 1))
As you can see, the only difference is that you test if the first element is a list, and if it is, you reverse the first element before appending it.