Hi,
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.
Thanks
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.
(defun islist (x)
(if (not (listp x))
nil
(or (listp (car x)) (islist (cdr x)))))
also(defun islist (x)
(and (listp x)
(or (listp (car x)) (islist (cdr x)))))
If I said (islist '(a b c d)), the function should return nil, yet it always returns T. Also, my indentation may be wierd. I'm using Emacs right now and it only lets me tab a set amount per line. Whether that amount is correct or not I have no idea.Thanks