Handbook
Glossary
in? ( elt set -- ? )
Factor handbook
»
The language
»
Collections
»
Sets
»
Operations on sets
Next:
members ( set -- seq )
Vocabulary
sets
Inputs
elt
an
object
set
a
set
Outputs
?
a
boolean
Word description
Tests whether the element is a member of the set.
Each set type is expected to implement a method on this generic word as part of the set protocol.
Definition
IN:
sets
GENERIC:
in?
( elt set -- ? )
Methods
USING:
accessors
bit-sets
kernel
math
sequences
sets
;
M:
bit-set
in?
over
integer?
[
table>>
?nth
]
[
2drop
f
]
if
;
inline
USING:
hash-sets
hash-sets.private
kernel
sets
;
M:
hash-set
in?
key@
2nip
;
USING:
accessors
assocs
linked-sets
sets
;
M:
linked-set
in?
assoc>>
key?
;
USING:
kernel
math
math.order
ranges
ranges.private
sets
;
M:
range
in?
over
number?
[
>forward-range<
[
3dup
between?
]
dip
swap
[
nip
3dup
[
-
]
dip
/i
*
+
=
]
[
4drop
f
]
if
]
[
2drop
f
]
if
;
USING:
sequences
sets
;
M:
sequence
in?
member?
;
inline
USING:
hash-sets.wrapped
hash-sets.wrapped.private
sets
;
M:
wrapped-hash-set
in?
wrapper@
in?
;
inline