I have two items. The first, a-child
, is a list which contains an array as its first element and then some strings as the remaining elements. The other, mapped
, is a list which contains a number of arrays. By inspection, it's easy to see that a-child
is in mapped
, though I can't find a function which will find it for me.
I apologize for the poor lisp style below - I started a few days ago, so I haven't picked up all the conventions yet.
(defparameter a-child (list (#2A((1 2 3) (7 4 5) (9 8 6))) "U" "R" "R"))
(defparameter mapped (list (#2A((1 2 3) (7 4 5) (9 8 6))) (#2A((1 2 3) (4 5 6) (7 8 9)))))
(find (car a-child) mapped) ;;returns NIL
(member (car a-child) mapped) ;;returns NIL
(position (car a-child) mapped) ;;returns NIL
(equalp (car a-child) (car mapped)) ;;returns T
What function can I use to look for arrays within a list of arrays?? Thank you.
equal
is the ordinary comparison operator. Notably, it works intuitively on strings and vectors. It may be that the possibility of making circular lists in Lisp is the reason whyequal
was not chosen as the default.equal
doesn't need to be slower thaneql
when comparing different types, as it only needs to traverse the data structure if all its arguments are of the same type. – Aftertime