![]() |
|
Navigation |
Synopsis Apply a function to all (key, value) pairs in a map.
Function
map[&K, &V] mapper(map[&K, &V] M, &L (&K) F, &W (&V) G)
Usage
import Map;
Description Apply the functions
F and G to each key/value pair in a map and return the transformed map.
Examples
rascal>import Map; ok rascal>str prefix(str s) { return "X" + s; } str (str): str prefix(str); rascal>int incr(int x) { return x + 1; } int (int): int incr(int); rascal>mapper(("apple": 1, "pear": 2, "orange": 3), prefix, incr); map[str, int]: ("Xapple":2,"Xorange":4,"Xpear":3) ![]() |