Skip to main content
Version: 1.4.0

Mapping

We may want to change all the elements of a given set by applying to them a function. This is called a map operation, not to be confused with the map data structure. The predefined functional iterator implementing the mapped operation over sets is called Set.map and is used as follows.

const s: set<int> = Set.literal(list([5,1,2,2]));
// plus_one == Set.literal(list([6,2,3]))
const plus_one: set<int> = Set.map(i => i + 1, s);

Note: See the predefined namespace Set