zip-with-as ( ... seq quot: ( ... key -- ... value ) exemplar -- ... assoc )
Factor handbook » The language » Collections » Associative mapping operations » Associative mapping conversions

Prev:zip-with ( ... seq quot: ( ... key -- ... value ) -- ... alist )
Next:unzip ( assoc -- keys values )


Vocabulary
assocs

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


Outputs
assocan assoc


Examples
USING: assocs math prettyprint ; { 1 2 3 4 } [ sq ] H{ } zip-with-as .
H{ { 1 1 } { 2 4 } { 3 9 } { 4 16 } }


Word description
Zip a sequence with values generated by applying quot to each element in the sequence, outputting an assoc of type exemplar.

See also
unzip, zip, zip-as, zip-index, zip-index-as, zip-with

Definition


: zip-with-as
( ... seq quot: ( ... key -- ... value ) exemplar -- ... assoc )
[ [ 1check ] curry ] dip map>assoc ; inline