RepCad Posted September 4, 2022 Share Posted September 4, 2022 (edited) Hello everyone, I have a list of some numbers as text, for example : (it may has just one item) ("304" "352" "361") and there is another list which it has lots of members and it's sort based on first element like this : (("301" x y) ("304" x y) ("327" x y) ("331" x y) ("347" x y) ("352" x y) ("359" x y) ("361" x y)) Finally I want to retrieve this list from the two lists : (I mean each element of the first list should be search in the second list, if it's equal, the list is retrieved from the second list) (("304" x y) ("352" x y) ("361" x y)) Can someone give the fastest way to perform it ? Thanks in advance Edited September 4, 2022 by amir0914 Quote Link to comment Share on other sites More sharing options...
Tharwat Posted September 4, 2022 Share Posted September 4, 2022 (foreach str '("304" "352" "361") (if (setq ass (assoc str '(("301" x y) ("304" x y) ("327" x y) ("331" x y) ("347" x y) ("352" x y) ("359" x y) ("361" x y)))) (setq grp (cons ass grp)) ) ) 1 Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted September 4, 2022 Share Posted September 4, 2022 Another - (setq l1 '(("301" x y) ("304" x y) ("327" x y) ("331" x y) ("347" x y) ("352" x y) ("359" x y) ("361" x y)) l2 '("304" "352" "361") ) (vl-remove-if-not '(lambda ( x ) (member (car x) l2)) l1) 1 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.