Handbook
Glossary
intersect ( set1 set2 -- set )
Factor handbook
»
The language
»
Collections
»
Sets
»
Operations on sets
Prev:
diff ( set1 set2 -- set )
Next:
union ( set1 set2 -- set )
Vocabulary
sets
Inputs
set1
a
set
set2
a
set
Outputs
set
a
set
Word description
Outputs a set consisting of elements present in both
set1
and
set2
.This word has a default definition which works for all sets, but set implementations may override the default for efficiency.
Examples
USING: sets prettyprint ; { 1 2 3 } { 2 3 4 } intersect .
{ 2 3 }
See also
diff
,
union
Definition
IN:
sets
GENERIC:
intersect
( set1 set2 -- set )
Methods
USING:
bit-sets
bit-sets.private
math
sets
;
M:
bit-set
intersect
[
bitand
]
bit-set-op
;
USING:
hash-sets
hash-sets.private
kernel
sets
sets.private
;
M:
hash-set
intersect
over
hash-set?
[
small/large
dupd
array/tester
not-tombstones
filter-members
>hash-set
]
[
(intersect)
>hash-set
]
if
;
USING:
generic
kernel
ranges
ranges.private
sets
;
M:
range
intersect
over
range?
[
intersect-range
]
[
M\
range
intersect
(call-next-method)
]
if
;
USING:
kernel
sets
sets.private
;
M:
set
intersect
[
(intersect)
]
keep
set-like
;