I'm a junior in high school learning how to program in Lisp. It's just something that I'm doing on the side, not for a course or anything. I have experience only in Java from taking the AP Computer Science class. I've just started about a week ago, and I've gotten a copy of ANSI Common Lisp and am using whatever online resources I can find. So if you guys have any suggestions for additional resources I could use or general information about what Lisp is used for nowadays or anything Lisp related, I'd be happy to listen. Anything helps. But anyways, here's my question:
I'm doing an exercise from ANSI Common Lisp that is as follows: define a function that takes a list as an argument and returns true if one of its elements is a list (using only operators introduced in chapter 2).
Here are my two solutions, neither of which work. I've seen the solution to this exercise, but I am very curious as to why my solutions don't work.
Code: Select all
(defun islist (x)
(if (not (listp x))
nil
(or (listp (car x)) (islist (cdr x)))))
Code: Select all
(defun islist (x)
(and (listp x)
(or (listp (car x)) (islist (cdr x)))))
Thanks