0 Members and 1 Guest are viewing this topic.
Need help understanding how code can search a list and find items that have been choosen (and prompt "duplicate objects will be ignored") twice ...can any one offer a small simple routine for me to study...I have looked @ others code and the help menu but still can make the connection.
(if (not (member x lst)) (setq lst (cons x lst)))
- create a listCommand: (setq lst '(1 2 3 4))(1 2 3 4)Command: (member 3 lst)(3 4) <- notice member return something- create 'x'Command: (setq x 5)5Command: (member x lst)nil <- nope x is _not_ in the listCommand: (not (member x lst))T <- returns T (true) because 5 is not in the listCommand: (setq lst (cons x lst))(5 1 2 3 4) <- construct a new list and add 'x' to it- create 'x'Command: (setq x 6)6- now put it all togetherCommand: (if (not (member x lst))(setq lst (cons x lst)))(6 5 1 2 3 4)