is there a function like find in lisp that returns true instead of the element we’re trying to find?
example:
I want it to do
(find 'x '(a c x)) = t
not
(find 'x '(a c x)) = x
Also, the reason I am asking is because I am trying to reach the deepest element in a list. My plan was to flatten the list every time i recursively called it.
I would then stop the recursive call when
(mapcar 'atom list)
would tell me every atom in there is true.
Do you believe this is a good approach to this problem?
There’s no such function, but it can’t be easier to write one:
Also instead of
(mapcar 'atom list)you can use(every #`(eql t %) list), i.e. check that every item inlistis exactlyt. (Here#`()is syntactic sugar for one-argumentlambdas, that I use.)But overall it’s unclear, what you’re trying to achieve with all this. Can you elaborate on what you’re trying to do?