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-filter ( ... assoc quot: ( ... key value -- ... ? ) -- ... subassoc )


Vocabulary
assocs

Inputs and outputs
assocan assoc
quota quotation with stack effect ( ... key value -- ... newkey newvalue )
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