Reputation:
I have a file which name is dictionary.lisp
. That includes some words like
(defparameter *dictionary* '(
(a b a)
(a b a d i)
.
.
)
I try to find them as a list. I tried the followings
[5]> (find '((a b a d i)) *dictionary* :test 'equal )
NIL
[6]> (find '((a b a d i)) *dictionary* :test #'equalp )
NIL
[7]> (member '((a b a d i)) *dictionary* :test 'equal )
NIL
[8]> (member '((a b a d i)) *dictionary* :test #'equalp )
NIL
[9]> (find '((a b a d i)) *dictionary* :test #'subsetp )
NIL
Is there any lisp function that can return non-nil?
Upvotes: 0
Views: 60
Reputation: 139251
CL-USER 25 > (defparameter *dictionary* '((a b a) (a b a d i)))
*DICTIONARY*
CL-USER 26 > (defun my-find (list0 list1)
(and (find (first list0) list1 :test #'equal)
t))
MY-FIND
CL-USER 27 > (my-find '((a b a d i)) *dictionary*)
T
It just does not look like it will make much sense.
Upvotes: 1
Reputation: 85823
You need to use equal or equalp as your test, which you're doing in four of your examples. You also need to search for something that's actually in the list. For instance, The dictionary you've described contains the list of five symbols (a b a d i) as an element, but not the list ((a b a d i)) (which is a list containing a single element, and that element is a list of five symbols). This means you'd do (find '(a b a d i) … :test 'equal):
CL-USER> (defparameter *dictionary* '((a b a)
(a b a d i)))
*DICTIONARY*
CL-USER> (find '((a b a d i)) *dictionary* :test 'equal)
NIL
CL-USER> (find '(a b a d i) *dictionary* :test 'equal)
(A B A D I)
CL-USER> (find '(f o o) *dictionary* :test 'equal)
NIL
Upvotes: 3