1.4.10 Sets
(add-to-set-eq sym lst) → t |
sym : t |
lst : (if (symbolp sym) (true-listp lst) (symbol-listp lst)) |
Examples: |
> (add-to-set-eq 'hello nil) |
'(hello) |
> (add-to-set-eq 'hello (list 'hello 'goodbye)) |
'(hello goodbye) |
> (add-to-set-eq "hello" (list 'hello 'goodbye)) |
'("hello" hello goodbye) |
(add-to-set-eql x lst) → t |
x : t |
lst : (if (eqlablep x) (true-listp lst) (eqlable-listp lst)) |
Examples: |
> (add-to-set-eql 'hello nil) |
'(hello) |
> (add-to-set-eql 'hello (list 'hello 'goodbye)) |
'(hello goodbye) |
> (add-to-set-eql "hello" (list 'hello 'goodbye)) |
'("hello" hello goodbye) |
(add-to-set-equal s lst) → t |
s : t |
lst : (true-listp lst) |
Examples: |
> (add-to-set-equal "hello" (list "hello")) |
'("hello") |
> (add-to-set-equal 4 (list 1 2 3)) |
'(4 1 2 3) |
(intersectp-eq x y) → t |
x : (symbol-listp x) |
y : (symbol-listp y) |
Examples: |
> (intersectp-eq (list 'a 'b 'c) (list 'x 'y 'z)) |
'() |
> (intersectp-eq (list 'a 'b 'c) (list 'a 'y 'z)) |
't |
(intersectp-equal x y) → t |
x : (true-listp x) |
y : (true-listp y) |
Examples: |
> (intersectp-equal (list "a" "b" "c") (list "x" "y" "z")) |
'() |
> (intersectp-equal (list "a" "b" "c") (list "a" "y" "z")) |
't |
(set-difference-eq x y) → t |
x : (true-listp x) |
y : (and (true-listp y) (or (symbol-listp x) (symbol-listp y))) |
Computes the set difference of x from y. Uses eq for comparisons. Use this function for sets of symbols.
Examples: |
> (set-difference-eq (list 'a 'b 'c) (list 'a 'c)) |
'(b) |
> (set-difference-eq (list "string") (list 'a 'c)) |
'("string") |
> (set-difference-eq (list 'a 'c) (list "string")) |
'(a c) |
(set-difference-equal x y) → t |
x : (true-listp x) |
y : (true-listp y) |
Example: |
> (set-difference-equal (list "a" "b" "c") (list "a" "c")) |
'("b") |
(subsetp x y) → t |
x : t |
y : (if (eqlable-listp y) (true-listp x) (if (eqlable-listp x) (true-listp y) nil)) |
Examples: |
> (subsetp (list 1 2 3) (list 2 3)) |
'() |
> (subsetp (list 1 2 3) (list 1 2 3 4 5)) |
't |
> (subsetp (list "1" "2") (list 1 2 3)) |
'() |
> (subsetp (list 1 2) (list 1 "1" 2 "2")) |
't |
(subsetp-equal x y) → t |
x : (true-listp x) |
y : (true-listp y) |
Like subsetp, but uses member-equal to check each element for membership.
Examples: |
> (subsetp-equal (list "a" "b" "c") (list "b" "c")) |
'() |
> (subsetp-equal (list "a" "b" "c") (list "a" "b" "c" "d" "e")) |
't |
(union-eq x y) → t |
x : (symbol-listp x) |
y : (true-listp y) |
Creates the union of two lists of symbols. See union-equal.
(union-equal x y) → t |
x : (true-listp x) |
y : (true-listp y) |
Creates the union of two lists. Specifically, the resulting list is the same as one would get by first deleting the members of y from x, and then concatenating the result to the front of y
Example: |
> (union-equal (list "a" "b" "c") (list "c" "d" "e")) |
'("a" "b" "c" "d" "e") |
(member x lst) → t |
x : t |
lst : (if (eqlablep x) (true-listp l) (eqlable-listp l)) |
If x is in lst, returns x and all elements after it in lst. Otherwise returns nil. Uses eql as test.
Examples: |
> (member 3 '(1 2 3 4 5)) |
'(3 4 5) |
> (member 3 '(2 4 6 8 10)) |
'() |
> (member "abc" '(1 2 3)) |
'() |
(member-eq x lst) → t |
x : t |
lst : (if (symbolp x) (true-listp lst) (symbol-listp lst)) |
(member-equal a lst) → t |
a : t |
lst : (true-listp lst) |
Examples: |
> (member-equal "a" '("a" "b" "c")) |
'("a" "b" "c") |
> (member-equal "a" '("x" "y" "z")) |
'() |
> (member-equal 3 '(1 2 3 4 5)) |
'(3 4 5) |
> (member-equal "abc" (list "a" "b" "abc")) |
'("abc") |
(no-duplicatesp lst) → t |
lst : (eqlable-listp lst) |
Returns true if lst contains no duplicate elements. Uses eql as the test.
Examples: |
> (no-duplicatesp (list 1 2 3)) |
't |
> (no-duplicatesp (list 1 2 1)) |
'() |
(no-duplicatesp-equal lst) → t |
lst : (true-listp lst) |
Like no-duplicatesp, but uses equal as the test.
Examples: |
> (no-duplicatesp-equal (list "a" "b" "c")) |
't |
> (no-duplicatesp-equal (list "a" "b" "a")) |
'() |
(remove x lst) → t |
x : t |
lst : (if (eqlablep x) (true-listp lst) (eqlable-listp lst)) |
Examples: |
> (remove 3 (list 1 2 3 4)) |
'(1 2 4) |
> (remove 3 (list 5 6 7 8)) |
'(5 6 7 8) |
> (remove "abc" (list 1 2 3 4)) |
'(1 2 3 4) |
> (remove 2 (list 1 2 "abc" 4)) |
'(1 "abc" 4) |
(remove-eq x lst) → t |
x : t |
lst : (if (symbolp x) (true-listp lst) (symbol-listp lst)) |
(remove-equal x lst) → t |
x : t |
lst : (true-listp lst) |
Example: |
> (remove-equal "x" (list "w" "x" "y" "z")) |
'("w" "y" "z") |
(remove-duplicates lst) → t |
lst : (or (stringp l) (eqlable-listp l)) |
Remove duplicate items in the given list or string, using eql as the test.
Examples: |
> (remove-duplicates (list 1 2 2 3 2 4)) |
'(1 3 2 4) |
> (remove-duplicates "abCdCeCfFgh") |
"abdeCfFgh" |
(remove-duplicates-equal lst) → t |
lst : (true-listp lst) |
Remove duplicate items in the given list or string, using equal as the test.
Examples: |
> (remove-duplicates-equal (list "a" "b" "b" "c" "d" "b")) |
'("a" "c" "d" "b") |
> (remove-duplicates-equal (list 1 2 2 3 2 4)) |
'(1 3 2 4) |
(remove1 x lst) → t |
x : t |
lst : (if (eqlablep x) (true-listp lst) (eqlable-listp lst)) |
like remove, but only removes the first instance
Examples: |
> (remove1 3 (list 1 2 3 4)) |
'(1 2 4) |
> (remove1 3 (list 5 6 7 8)) |
'(5 6 7 8) |
> (remove1 "abc" (list 1 2 3 4)) |
'(1 2 3 4) |
> (remove1 2 (list 1 2 "abc" 4)) |
'(1 "abc" 4) |
(remove1-eq x lst) → t |
x : t |
lst : (if (symbolp x) (true-listp lst) (symbol-listp lst)) |
like remove-eq, but only removes the first instance
Example: |
> (remove1-eq 'x (list 'w 'x 'x 'y 'x 'z)) |
'(w x y x z) |
(remove1-equal x lst) → t |
x : t |
lst : (true-listp lst) |
Like remove-equal, but only removes the first instance
Example: |
> (remove1-equal "x" (list "w" "x" "x" "y" "x" "z")) |
'("w" "x" "y" "x" "z") |