I have to write a function that checks if an item is in a tree.
For example:
(defun find-in-tree (item tree)
...)
(find-in-tree 2 '(1 (3 4 (2))) 2) ;; should give T
(find-in-tree 2 '(1 (3 4))) ;; should give NIL
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Quoting On Lisp:
Few examples:
Now, a recursive version of
find:Usage:
You can find out more about lists, trees, recursive functions and recursive search in SICP, On Lisp and PAIP.
There is also a question of whether these functions are tail-recursive or not. Such issues are also discussed in listed books.