Handbook
Glossary
adjoin ( elt set -- )
Factor handbook
»
The language
»
Collections
»
Sets
»
Operations on sets
Prev:
cardinality ( set -- n )
Next:
delete ( elt set -- )
Vocabulary
sets
Inputs
elt
an
object
set
a
set
Outputs
None
Word description
Destructively adds
elt
to
set
. For sequences, this guarantees that this element is not duplicated, and that it is at the end of the sequence.
Each mutable set type is expected to implement a method on this generic word.
Examples
USING: prettyprint sets kernel ; V{ "beans" "salsa" "cheese" } clone "nachos" over adjoin "salsa" over adjoin .
V{ "beans" "cheese" "nachos" "salsa" }
Side effects
Modifies
set
Definition
IN:
sets
GENERIC:
adjoin
( elt set -- )
Methods
USING:
accessors
bit-sets
kernel
sequences
sets
;
M:
bit-set
adjoin
[
t
]
2dip
table>>
set-nth
;
USING:
hash-sets
hash-sets.private
kernel
sets
;
M:
hash-set
adjoin
dup
?grow-hash
(adjoin)
drop
;
USING:
accessors
assocs
deques
kernel
linked-sets
linked-sets.private
sets
;
M:
linked-set
adjoin
[
assoc>>
]
[
dlist>>
]
bi
[
2over
key?
[
3dup
(delete-at)
]
when
nip
push-back*
]
curry
[
set-at
]
2bi
;
USING:
kernel
sequences
sets
;
M:
sequence
adjoin
[
delete
]
[
push
]
2bi
;
USING:
hash-sets.wrapped
hash-sets.wrapped.private
sets
;
M:
wrapped-hash-set
adjoin
wrapper@
adjoin
;
inline