Navigation
Synopsis Apply a function to all list elements and return list of results.
Function list[&U] mapper(list[&T] lst, &U (&T) fn)
Usage import List;
Description Apply a function fn to each element of lst and return the list of results.
Examples
rascal>import List;
ok
rascal>int incr(int x) { return x + 1; }
int (int): int incr(int);
rascal>mapper([1, 2, 3, 4], incr);
list[int]: [2,3,4,5]

Questions
Question [1].
Given
int incr(int x) { return x + 1; }
The type of mapper([18, 17, -14], incr) is

Question [2].
Given
int incr(int x) { return x + 1; }
mapper([14, 9, -12, -14], 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.