2.4.10 Sets
sym : t |
lst : (if (symbolp sym) (true-listp lst) (symbol-listp lst)) |
Adds sym to lst if it is not already present. Uses eq for comparisons.
Examples: |
> (add-to-set-eq 'hello nil) |
(hello) |
> (add-to-set-eq 'hello (list 'goodbye)) |
(hello goodbye) |
> (add-to-set-eq 'hello (list 'hello 'goodbye)) |
(hello goodbye) |
> (add-to-set-eq "string" (list 'hello 'goodbye)) |
("string" hello goodbye) |
> (add-to-set-eq 4 (list 1 2 3)) |
/Users/cce/plt/research/dracula/release/src/language/checkin |
g-proc.scm:36:21: Dracula program broke the contract (->r |
((x ...) (y ...)) ...) on here; expected <symbolp>, given: 1 |
> (add-to-set-eq "string1" (list "string2")) |
/Users/cce/plt/research/dracula/release/src/language/checkin |
g-proc.scm:36:21: Dracula program broke the contract (->r |
((x ...) (y ...)) ...) on here; expected <symbolp>, given: |
"string2" |
x : t |
lst : (if (eqlablep x) (true-listp lst) (eqlable-listp lst)) |
Adds x to lst if it is not already present. Uses eql for comparisons.
Examples: |
> (add-to-set-eql 'hello nil) |
(hello) |
> (add-to-set-eql 'hello (list 'hello)) |
(hello) |
> (add-to-set-eql 1 (list 'hello 1 'bye 2)) |
(hello 1 bye 2) |
> (add-to-set-eql "string1" (list "string2")) |
/Users/cce/plt/research/dracula/release/src/language/checkin |
g-proc.scm:36:21: Dracula program broke the contract (->r |
((x ...) (y ...)) ...) on here; expected <eqlablep>, given: |
"string2" |
s : t |
lst : (true-listp lst) |
Adds x to lst if it is not already present. Uses equal for comparisons.
Examples: |
> (add-to-set-equal "hello" nil) |
("hello") |
> (add-to-set-equal "hello" (list "hello")) |
("hello") |
> (add-to-set-eq 4 (list 1 2 3)) |
/Users/cce/plt/research/dracula/release/src/language/checkin |
g-proc.scm:36:21: Dracula program broke the contract (->r |
((x ...) (y ...)) ...) on here; expected <symbolp>, given: 1 |
> (add-to-set-equal "string1" (list "string2")) |
("string1" "string2") |
> (add-to-set-equal 1 "string") |
/Users/cce/plt/research/dracula/release/src/language/checkin |
g-proc.scm:36:21: Dracula program broke the contract (-> |
(or/c "nil" (cons/c any/c any/c)) any) on here; expected |
<(or/c nil (cons/c any/c any/c))>, given: "string" |
x : (symbol-listp x) |
y : (symbol-listp y) |
Determines if x and y share at least one element in common. Uses eq for comparisons.
Examples: |
> (intersectp-eq (list 'a 'b 'c) (list 'x 'y 'z)) |
() |
> (intersectp-eq (list 'a 'b 'c) (list 'a 'y 'z)) |
t |
> (intersectp-eq (list 'a "b" 'c) (list 'a 'y 'z)) |
/Users/cce/plt/research/dracula/release/src/language/checkin |
g-proc.scm:36:21: Dracula program broke the contract (-> |
(listof acl2-symbol?) (listof acl2-symbol?) any) |
on here; expected <(listof acl2-symbol?)>, given: (a "b" c) |
x : (true-listp x) |
y : (true-listp y) |
Determines if x and y share at least one element in common. Uses equal for comparisons.
Examples: |
> (intersectp-equal (list "a" "b" "c") (list "x" "y" "z")) |
() |
> (intersectp-equal (list "a" "b" "c") (list "a" "y" "z")) |
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-eq (list "string1") (list "string2")) |
/Users/cce/plt/research/dracula/release/src/language/checkin |
g-proc.scm:36:21: Dracula program broke the contract (->r |
((x ...) (y ...)) ...) on here; expected <symbolp>, given: |
"string2" |
x : (true-listp x) |
y : (true-listp y) |
Computes the set difference of the lists x and y. Uses equal for comparisons.
Examples: |
> (set-difference-equal (list "a" "b" "c") (list "a" "c")) |
("b") |
> (set-difference-equal "abc" "bc") |
/Users/cce/plt/research/dracula/release/src/language/checkin |
g-proc.scm:36:21: Dracula program broke the contract (-> |
(or/c "nil" (cons/c any/c any/c)) any) on here; expected |
<(or/c nil (cons/c any/c any/c))>, given: "abc" |
x : t |
y : (if (eqlable-listp y) (true-listp x) (if (eqlable-listp x) (true-listp y) nil)) |
Determines whether every element of x a member of y.
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 (list "1" "2") (list "1" "2" "3" "4")) |
/Users/cce/plt/research/dracula/release/src/language/checkin |
g-proc.scm:36:21: Dracula program broke the contract (->r |
((x ...) (y ...)) ...) on here; expected <eqlablep>, given: |
"1" |
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 |
> (subsetp-equal "not a list" (list 1 2 3)) |
/Users/cce/plt/research/dracula/release/src/language/checkin |
g-proc.scm:36:21: Dracula program broke the contract (-> |
(or/c "nil" pair?) any) on here; expected <(or/c nil |
pair?)>, given: "not a list" |
x : (symbol-listp x) |
y : (true-listp y) |
Creates the union of two lists of symbols. See union-equal.
Examples: |
> (union-eq (list 'a 'b 'c) (list 'c 'd 'e)) |
(a b c d e) |
> (union-eq (list 1 2 3) (list 'a 'b 'c)) |
(1 2 3 a b c) |
> (union-eq (list 'a 'b 'c) "not a list") |
/Users/cce/plt/research/dracula/release/src/language/checkin |
g-proc.scm:36:21: Dracula program broke the contract (-> |
(or/c "nil" (cons/c any/c any/c)) any) on here; expected |
<(or/c nil (cons/c any/c any/c))>, given: "not a list" |
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
Examples: |
> (union-equal (list "a" "b" "c") (list "c" "d" "e")) |
("a" "b" "c" "d" "e") |
> (union-equal "not a list" (list 1 2 3)) |
/Users/cce/plt/research/dracula/release/src/language/checkin |
g-proc.scm:36:21: Dracula program broke the contract (-> |
(or/c "nil" pair?) any) on here; expected <(or/c nil |
pair?)>, given: "not a list" |
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 "abc" ("a" "b" "abc")) |
eval:508:0: #%app: Expected the name of a function here at: |
"a" in: (#%app "a" "b" "abc") |
x : t |
lst : (if (symbolp x) (true-listp lst) (symbol-listp lst)) |
Like member, but uses eq as test.
Examples: |
> (member-eq 'a '(a b c)) |
(a b c) |
> (member-eq 'a '(x y z)) |
() |
> (member-eq 3 '(1 2 3 4 5)) |
/Users/cce/plt/research/dracula/release/src/language/checkin |
g-proc.scm:36:21: Dracula program broke the contract (->r |
((x ...) (y ...)) ...) on here; expected <symbolp>, given: 1 |
> (member-eq "abc" (list "a" "b" "abc")) |
/Users/cce/plt/research/dracula/release/src/language/checkin |
g-proc.scm:36:21: Dracula program broke the contract (->r |
((x ...) (y ...)) ...) on here; expected <symbolp>, given: |
"a" |
a : t |
lst : (true-listp lst) |
Like member, but uses equal as test.
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") |
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 (list "a" "b" "a")) |
/Users/cce/plt/research/dracula/release/src/language/checkin |
g-proc.scm:36:21: Dracula program broke the contract (->r |
((x ...) (y ...)) ...) on here; expected <eqlablep>, given: |
"b" |
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")) |
() |
x : t |
lst : (if (eqlablep x) (true-listp lst) (eqlable-listp lst)) |
Removes all occurrences of x from lst, using eql as the test
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 "abc" (list 1 2 "abc" 4)) |
/Users/cce/plt/research/dracula/release/src/language/checkin |
g-proc.scm:36:21: Dracula program broke the contract (->r |
((x ...) (y ...)) ...) on here; expected <eqlablep>, given: |
"abc" |
x : t |
lst : (if (symbolp x) (true-listp lst) (symbol-listp lst)) |
Removes all occurrences of x from lst, using eq as the test
Examples: |
> (remove-eq 'x (list 'w 'x 'y 'z)) |
(w y z) |
> (remove-eq 'x "wxyz") |
/Users/cce/plt/research/dracula/release/src/language/checkin |
g-proc.scm:36:21: Dracula program broke the contract (-> |
(or/c "nil" (cons/c any/c any/c)) any) on here; expected |
<(or/c nil (cons/c any/c any/c))>, given: "wxyz" |
> (remove-eq 2 (list 1 2 3 4)) |
/Users/cce/plt/research/dracula/release/src/language/checkin |
g-proc.scm:36:21: Dracula program broke the contract (->r |
((x ...) (y ...)) ...) on here; expected <symbolp>, given: 1 |
x : t |
lst : (true-listp lst) |
Examples: |
> (remove-equal "x" (list "w" "x" "y" "z")) |
("w" "y" "z") |
> (remove-equal "x" "wxyz") |
/Users/cce/plt/research/dracula/release/src/language/checkin |
g-proc.scm:36:21: Dracula program broke the contract (-> |
(or/c "nil" (cons/c any/c any/c)) any) on here; expected |
<(or/c nil (cons/c any/c any/c))>, given: "wxyz" |
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 (list "a" "b" "c" "a" "d" "e")) |
/Users/cce/plt/research/dracula/release/src/language/checkin |
g-proc.scm:36:21: Dracula program broke the contract (->r |
((x ...) (y ...)) ...) on here; expected <eqlablep>, given: |
"b" |
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) |
> (remove-duplicates-equal "abCdCeCfFgh") |
/Users/cce/plt/research/dracula/release/src/language/checkin |
g-proc.scm:36:21: Dracula program broke the contract (-> |
(or/c "nil" pair?) any) on here; expected <(or/c nil |
pair?)>, given: "abCdCeCfFgh" |
> (remove-duplicates-equal 6) |
/Users/cce/plt/research/dracula/release/src/language/checkin |
g-proc.scm:36:21: Dracula program broke the contract (-> |
(or/c "nil" pair?) any) on here; expected <(or/c nil |
pair?)>, given: 6 |
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 "abc" (list 1 2 "abc" 4)) |
/Users/cce/plt/research/dracula/release/src/language/checkin |
g-proc.scm:36:21: Dracula program broke the contract (->r |
((x ...) (y ...)) ...) on here; expected <eqlablep>, given: |
"abc" |
x : t |
lst : (if (symbolp x) (true-listp lst) (symbol-listp lst)) |
like remove-eq, but only removes the first instance
Examples: |
> (remove1-eq 'x (list 'w 'x 'x 'y 'x 'z)) |
(w x y x z) |
> (remove1-eq 'x "wxyz") |
/Users/cce/plt/research/dracula/release/src/language/checkin |
g-proc.scm:36:21: Dracula program broke the contract (-> |
(or/c "nil" pair?) any) on here; expected <(or/c nil |
pair?)>, given: "wxyz" |
> (remove1-eq 2 (list 1 2 2 3 4)) |
/Users/cce/plt/research/dracula/release/src/language/checkin |
g-proc.scm:36:21: Dracula program broke the contract (->r |
((x ...) (y ...)) ...) on here; expected <symbolp>, given: 1 |
x : t |
lst : (true-listp lst) |
Like remove-equal, but only removes the first instance
Examples: |
> (remove1-equal "x" (list "w" "x" "x" "y" "x" "z")) |
("w" "x" "y" "x" "z") |
> (remove-equal "x" "wxyz") |
/Users/cce/plt/research/dracula/release/src/language/checkin |
g-proc.scm:36:21: Dracula program broke the contract (-> |
(or/c "nil" (cons/c any/c any/c)) any) on here; expected |
<(or/c nil (cons/c any/c any/c))>, given: "wxyz" |