Handbook
Glossary
map>assoc ( ... seq quot: ( ... elt -- ... key value ) exemplar -- ... assoc )
Factor handbook
»
The language
»
Collections
»
Associative mapping operations
»
Associative mapping combinators
Prev:
harvest-values ( assoc -- assoc' )
Next:
map>alist ( ... seq quot: ( ... elt -- ... key value ) -- ... alist )
Vocabulary
assocs
Inputs
seq
a
sequence
quot
a
quotation
with stack effect
( ... elt -- ... key value )
exemplar
an
assoc
Outputs
assoc
a new assoc
Word description
Applies the quotation to each element of the sequence, and collects the keys and values into a new assoc having the same type as
exemplar
.
See also
map>alist
Definition
USING:
arrays
kernel
sequences
;
IN:
assocs
:
map>assoc
( ... seq quot: ( ... elt -- ... key value ) exemplar -- ... assoc )
dup
sequence?
[
[
[
2array
]
compose
]
dip
map-as
]
[
[
over
assoc-size
]
dip
new-assoc
[
[
swapd
set-at
]
curry
compose
each
]
keep
]
if
;
inline