Write the function UNION which computes the set theoretic
union of two lists. For example,
(union '(a b c d) '(c a g))
returns the list (a b c d g)
union-help
-
- Posts: 59
- Joined: Sun May 29, 2011 8:52 pm
- Location: NY
- Contact:
Re: union-help
Really should try to post some code so people aren't just giving you the answer, but here's something to get you started on solving your problems.
This simply asks for two lists, combines them, and then removes the duplicates. As union does.
Code: Select all
(defun my-union (list1 list2)
(remove-duplicates (append list1 list2) :from-end t))
Code: Select all
COMMON-LISP-USER>
(my-union '(a b c d) '(c a g))
(A B C D G)