assoc-map ( ... assoc quot: ( ... key value -- ... newkey newvalue ) -- ... newassoc )
Factor handbook » The language » Collections » Associative mapping operations » Associative mapping combinators

Prev:assoc-find ( ... assoc quot: ( ... key value -- ... ? ) -- ... key value ? )
Next:assoc-map-as ( ... assoc quot: ( ... key value -- ... newkey newvalue ) exemplar -- ... newassoc )


Vocabulary
assocs

Inputs
assocan assoc
quota quotation with stack effect ( ... key value -- ... newkey newvalue )


Outputs
newassoca new assoc


Word description
Applies the quotation to each entry in the input assoc and collects the results in a new assoc of the same type as the input.

Examples
: discount ( prices n -- newprices ) [ - ] curry assoc-map ; H{ { "bananas" 5 } { "apples" 42 } { "pears" 17 } } 2 discount .
H{ { "bananas" 3 } { "apples" 40 } { "pears" 15 } }


See also
assoc-map-as

Definition


: assoc-map
( ... assoc quot: ( ... key value -- ... newkey newvalue ) -- ... newassoc )
over assoc-map-as ; inline