zip-with-as ( ... seq quot: ( ... key -- ... value ) exemplar -- ... assoc ) (original) (raw)
Vocabulary
assocs
Inputs
seq | a sequence |
---|---|
quot | a quotation with stack effect ( ... key -- ... value ) |
exemplar | an assoc |
Outputs
assoc | an 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