Name

mapmap — Maps an operation onto all key/value pairs of a map

Synopsis

map mapmap ( any KEY ,
  any VALUE ,
  map MAP ,
  block EXPR );
 

Parameters

any KEY

any VALUE

map MAP

block EXPR

Return

map

Description

Maps an operation onto all key/value pairs of the map MAP and thus creates a new map. For each key/value pair of the map MAP the expression EXPR is evaluated in a new block, where the variable KEY is assigned to the key and VALUE to the value of the pair. The result is the map of those evaluations.

The result of each evaluation must be a map with a single entry which will be added to the result map.

Usage

  mapmap (integer k, string v, $[1:"a", 2:"b"], { return ($[k+10 : v+"x"]); }) -> $[ 11:"ax", 12:"bx" ]
  mapmap (integer k, string v, $[1:"a", 2:"b"], { integer a = k + 10; string b = v + "x"; return $[a:b]; }) -> $[ 11:"ax", 12:"bx" ]