I am a new lisp programmer and I am trying to create my first recursive lisp function to return the larger of two lists. Every time I run the function it seems to crash as I guess my base case isn't being met. Here's the code I have.
(defun longest (l1 l2)
(cond ((null l1) (l2))
((null l2) (l1))
(t (rest l1)
(rest l2)
(longest l1 l2))
)
)
I know this wouldn't work for the case when both lists are the same length, but I just wanted to get something working first. I understand this could also be achieved with a while loop but for the purpose of learning I wanted to use recursion.
Why does this code never terminate?