In particular, I just want to ensure that two lists have the same elements, ignoring order
相关问题
- Generating powerset in one function, no explicit r
- Drakma and Dexador both fails at USocket call whil
- Forming Lisp code to task — related to flatten lis
- clisp 2.49: asdf cannot find asd
- unfold function in scheme
相关文章
- Does learning one Lisp help in learning the other?
- Common Lisp: Why does my tail-recursive function c
- What is the definition of “natural recursion”?
- How do I write a macro-defining macro in common li
- How can I unintern a qualified method?
- Changing the nth element of a list
- Is a “transparent” macrolet possible?
- sleep in emacs lisp
If order isn't important, you can use equal. For instance,
is true. Thus one way to do it would be to (sort) the list and then use equal. Note that sort is destructive so if order matters, you might want to copy it first.
If repeating items are not important see also SET-EXCLUSIVE-OR.
Sort both lists, then compare:
If the order isn't important you can use "equal-set":
(equal-sets
(1 2)
(1 2)) -> T(equal-sets
(1 2)
(2 1)) -> T(equal-sets
(1 2 5)
(1 2)) -> NIL(equal-sets
(1 2)
(1 5 2)) -> NIL