list c = list a - list b?

tsigwing

Usenet Archive
Joined
Jun 26, 2003
Messages
76
Reaction score
0
I know there has to be a simple way to subtract the contents of one list from another. Any help?
 
any practical sample that i can take a look - to test.?

tsigwing said:
I know there has to be a simple way to subtract the contents of one list
from another. Any help?
 
Responding to keyword "simple", and a fuzzy understanding what you mean "contents of one list from another" ...

(setq
list1 '(1 2 3 4 5)
list2 '(2 3 4)
)

(vl-remove-if
'(lambda (x) (member x list2))
list1
)

returns (1 5)

I know there has to be a simple way to subtract the contents of one list from another. Any help?
 
Hi michael puckett , how about this below I would "(- list1 list2)"

_$ (setq list1 '(1.9 2.8 3.7 4.8 5.7))

(1.9 2.8 3.7 4.8 5.7)

_$ (setq list2 '(1.1 2.2 3.3 4.1 5.5))

(1.1 2.2 3.3 4.1 5.5)
 
Or, alternatively,

(setq list_c nil)
(foreach el list_a
(or (member el list_b)(setq list_c (cons el list_c)))
)
 
?????????????????????

_ (setq list_a '(1.9 2.8 3.7 4.8 5.7))
(1.9 2.8 3.7 4.8 5.7)
_$ (setq list_b '(1.1 2.2 3.3 4.1 5.5))
(1.1 2.2 3.3 4.1 5.5)
_$ (setq list_c nil)
nil
_$ (foreach el list_a
(or (member el list_b)(setq list_c (cons el list_c))))
T
 
the expression itself returns T (that's the return value of or) but look at the value of list_c.
 

Latest threads

Back
Top