TheSwamp
Code Red => AutoLISP (Vanilla / Visual) => Topic started by: fools on December 04, 2017, 09:45:07 AM
-
Input list:
(setq lst1 '(("1D61" "1D62")
("1D61" "1D62")
("1D63" "1D64" "1DB6")
("1D63" "1D64" "1D65")
("1D64" "1D65" "1D66")
("1D65" "1D66" "1D67")
("1D66" "1D67" "1D68")
("1D67" "1D68" "1DBE")
("1D7F" "1D80")
("1D7F" "1D80")
("1D81" "1D82" "1D83")
("1D81" "1D82" "1D83" "1D85")
("1D81" "1D82" "1D83")
("1D84" "1D85" "1D86")
("1D82" "1D84" "1D85" "1D86")
("1D84" "1D85" "1D86")
("1D63" "1DB6" "1DBF")
("1D68" "1DBE")
("1DB6" "1DBF")
)
)
Each of the sublists in the output list has different elements.
Output list:
(setq lst2 '(("1D61" "1D62")
("1D63" "1D64" "1D65" "1D66" "1D67" "1D68" "1DB6" "1DBE" "1DBF")
("1D7F" "1D80")
("1D81" "1D82" "1D83" "1D84" "1D85" "1D86")
)
)
It's my way, but it's too tedious.I hope to improve the combined efficiency.
All suggestions and opinions are welcome. Thanks.
(defun foo
(lst
/ item more out same tmp
) more t
)
)
)
)
)
)
)
out
)
)
)
)
-
How about:
(defun foo
( lst
/ rtn tmp
) )
)
)
-
How about:
Lee, thank you very much. Whenever I meet a problem, I can always get your help.
When the amount of data is large, your program is so many times faster than mine.
-
How about:(defun foo
( lst
/ rtn tmp
) )
)
)
A little bug. :cry:
When two adjacent items are different and have some same items with the following, will return error result.
Like this:
(setq lst '(("1D22" "1DC7") ("1D23" "1D24") ("1D24" "1DC7")))
(foo lst) --> (("1D22" "1DC7") ("1D23" "1D24" "1DC7"))
The correct result is (("1D22" "1D23" "1D24" "1DC7"))
-
How about :
(defun foogather
( lst
/ foo rtn
)
(defun foo
( lst
/ rtn tmp
) )
)
)
rtn
)
Untested though...
-
How about :
Thanks for reply.
This is really a way, but perhaps also have some optimized space.