set-subset? to subset?
This commit is contained in:
parent
72431fda2d
commit
76754c5443
|
@ -6,7 +6,7 @@
|
||||||
set-empty? set-count
|
set-empty? set-count
|
||||||
set-member? set-add set-remove
|
set-member? set-add set-remove
|
||||||
set-union set-intersect set-subtract
|
set-union set-intersect set-subtract
|
||||||
set-subset?
|
subset?
|
||||||
set-map set-for-each
|
set-map set-for-each
|
||||||
(rename-out [*in-set in-set])
|
(rename-out [*in-set in-set])
|
||||||
for/set for/seteq for/seteqv
|
for/set for/seteq for/seteqv
|
||||||
|
@ -164,9 +164,9 @@
|
||||||
(for/fold ([set set]) ([set2 (in-list sets)])
|
(for/fold ([set set]) ([set2 (in-list sets)])
|
||||||
(set-subtract set set2))]))
|
(set-subtract set set2))]))
|
||||||
|
|
||||||
(define (set-subset? set1 set2)
|
(define (subset? set2 set1)
|
||||||
(unless (set? set1) (raise-type-error 'set-subset? "set" 0 set1 set2))
|
(unless (set? set2) (raise-type-error 'subset? "set" 0 set2 set1))
|
||||||
(unless (set? set2) (raise-type-error 'set-subset? "set" 1 set1 set2))
|
(unless (set? set1) (raise-type-error 'subset? "set" 0 set2 set1))
|
||||||
(let ([ht1 (set-ht set1)]
|
(let ([ht1 (set-ht set1)]
|
||||||
[ht2 (set-ht set2)])
|
[ht2 (set-ht set2)])
|
||||||
(unless (and (eq? (hash-eq? ht1) (hash-eq? ht2))
|
(unless (and (eq? (hash-eq? ht1) (hash-eq? ht2))
|
||||||
|
|
|
@ -103,13 +103,13 @@ runs in time proportional to the total size of all given
|
||||||
@scheme[set]s except the first one.}
|
@scheme[set]s except the first one.}
|
||||||
|
|
||||||
|
|
||||||
@defproc[(set-subset? [set set?] [set2 set?]) boolean?]{
|
@defproc[(subset? [set set?] [set2 set?]) boolean?]{
|
||||||
|
|
||||||
Returns @scheme[#t] if every member of @scheme[set2] is in
|
Returns @scheme[#t] if every member of @scheme[set] is in
|
||||||
@scheme[set], @scheme[#f] otherwise. The @scheme[set] and
|
@scheme[set2], @scheme[#f] otherwise. The @scheme[set] and
|
||||||
@scheme[set2] must use the same equivalence predicate
|
@scheme[set2] must use the same equivalence predicate
|
||||||
(@scheme[equal?], @scheme[eq?], or @scheme[eqv?]). This operation
|
(@scheme[equal?], @scheme[eq?], or @scheme[eqv?]). This operation
|
||||||
runs in time proportional to the size of @scheme[set2].}
|
runs in time proportional to the size of @scheme[set].}
|
||||||
|
|
||||||
|
|
||||||
@defproc[(set-map [set set?]
|
@defproc[(set-map [set set?]
|
||||||
|
|
|
@ -50,10 +50,10 @@
|
||||||
(test #t set-member? (set-remove s 5) 3)
|
(test #t set-member? (set-remove s 5) 3)
|
||||||
(test #f set-member? (set-remove s 3) 3)
|
(test #f set-member? (set-remove s 3) 3)
|
||||||
|
|
||||||
(test #t set-subset? s (set 1 3))
|
(test #t subset? (set 1 3) s)
|
||||||
(test #t set-subset? s (set 1 2 3))
|
(test #t subset? (set 1 2 3) s)
|
||||||
(test #f set-subset? s (set 1 4))
|
(test #f subset? (set 1 4) s)
|
||||||
(test #t set-subset? s (set))
|
(test #t subset? (set) s)
|
||||||
|
|
||||||
(test 3 set-count (set-union s))
|
(test 3 set-count (set-union s))
|
||||||
(test 6 set-count (set-union s (set 3 4 5 6)))
|
(test 6 set-count (set-union s (set 3 4 5 6)))
|
||||||
|
|
Loading…
Reference in New Issue
Block a user