Navigation
Synopsis Apply a function to all set elements and return set of results.
Function set[&U] mapper(set[&T] st, &U (&T) fn)
Usage import Set;
Description Return a set obtained by applying function fn to all elements of set s.
Examples
rascal>import Set;
ok
rascal>int incr(int x) { return x + 1; }
int (int): int incr(int);
rascal>mapper({1, 2, 3, 4}, incr);
set[int]: {2,3,4,5}

Questions
Question [1].
Given
int incr(int x) { return x + 1; }
The type of mapper({11, -3, -8, -7, 5}, incr) is

Question [2].
Given
int incr(int x) { return x + 1; }
mapper({-11, -9, 13, 17, -10}, incr) == 



Is this page unclear, or have you spotted an error? Please add a comment below and help us to improve it. For all other questions and remarks, visit ask.rascal-mpl.org.