Handbook
Glossary
intersects? ( set1 set2 -- ? )
Factor handbook
»
The language
»
Collections
»
Sets
»
Operations on sets
Prev:
union ( set1 set2 -- set )
Next:
subset? ( set1 set2 -- ? )
Vocabulary
sets
Inputs
set1
a
set
set2
a
set
Outputs
?
a
boolean
Word description
Tests if
set1
and
set2
have any elements in common.
Notes
If one of the sets is empty, the result is always
f
.
Definition
IN:
sets
GENERIC:
intersects?
( set1 set2 -- ? )
Methods
USING:
hash-sets
hash-sets.private
kernel
sequences
sets
sets.private
;
M:
hash-set
intersects?
over
hash-set?
[
small/large
array/tester
not-tombstones
any?
]
[
small/large
sequence/tester
any?
]
if
;
USING:
accessors
generic
kernel
math
ranges
ranges.private
sets
;
M:
range
intersects?
over
range?
[
intersect-range
length>>
zero?
not
]
[
M\
range
intersects?
(call-next-method)
]
if
;
USING:
sequences
sets
sets.private
;
M:
set
intersects?
small/large
sequence/tester
any?
;