Vocabulary
assocs

Inputs
seqa sequence
quota quotation with stack effect ( ... elt -- ... key value )
exemplaran assoc


Outputs
assoca 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


: 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