Hello,
I've got an unexpected behavior in OpenMCL when programming some
examples on recursion for my students. The function skip-first-n
(elimina-primeros-n in spanish), can be defined as:
CL-USER> (defun elimina-primeros-n-rec (n lst)
(cond ((zerop n) lst)
(t (elimina-primeros-n-rec (- n 1) (cdr
lst)))))
ELIMINA-PRIMEROS-N-REC
CL-USER> (elimina-primeros-n 3 '(1 2 3 4 5 6))
(1 2 3 4 5 6)
but, as shown, the function is not working as expected! I've tried the
same definition on LispWorks, obtaining:
CL-USER 1 > (defun elimina-primeros-n-rec (n lst)
(cond ((eq n 0) lst)
(t (elimina-primeros-n-rec (- n 1) (cdr lst)))))
CL-USER 2 > (elimina-primeros-n-rec 3 '(1 2 3 4 5 6))
(4 5 6)
Why is OpenMCL behaving in this way?