Reputation: 119
I know how to check if an item is in a list: (when (member item list :test #'equalp))
. If I have a list of structs book :
(defstruct book
name
author
)
how do I check if a book from a certain author is a member of the list (independently of the name)? I know this is a very beginner question and I did try to find the answer by myself but did not succeed.
Upvotes: 1
Views: 233
Reputation: 60004
What you are looking for is :key
argument:
(find author library :test #'string= :key #'book-author)
Same with member
:
(member (book-name my-book) library :test #'string= :key #'book-name)
Note that :key
is not called on the item
.
Upvotes: 2