Handbook
Glossary
set= ( set1 set2 -- ? )
Factor handbook
»
The language
»
Collections
»
Sets
»
Operations on sets
Prev:
subset? ( set1 set2 -- ? )
Next:
union-all ( sets -- set/f )
Vocabulary
sets
Inputs
set1
a
set
set2
a
set
Outputs
?
a
boolean
Word description
Tests if both sets contain the same elements, disregarding order and duplicates.
Definition
IN:
sets
GENERIC:
set=
( set1 set2 -- ? )
Methods
USING:
generic
hash-sets
hash-sets.private
kernel
sequences
sets
;
M:
hash-set
set=
over
hash-set?
[
2dup
[
cardinality
]
bi@
eq?
[
array/tester
and-tombstones
all?
]
[
2drop
f
]
if
]
[
M\
hash-set
set=
(call-next-method)
]
if
;
USING:
generic
kernel
ranges
ranges.private
sequences
sets
;
M:
range
set=
over
range?
[
[
[
empty-range
]
[
forward-range
]
if-empty
]
bi@
=
]
[
M\
range
set=
(call-next-method)
]
if
;
USING:
kernel
sets
sets.private
;
M:
set
set=
2dup
[
cardinality
]
bi@
=
[
(subset?)
]
[
2drop
f
]
if
;