BoxSetMap
Apply a transform function to every element of a Set and collect the deduplicated results into a new Set of the same variant.
The source Set is not modified. The callback receives the element value, its 1-based ordinal position, and the original Set.
Method Signature
BoxSetMap(set=[set], callback=[function:Function])Arguments
Argument
Type
Required
Description
Default
set
set
true
The source set to transform.
callback
function:Function
true
Receives {@code (value, ordinal, set)} and returns the transformed value.
Examples
Transform each element and return a new Set
The callback receives each value and must return the replacement value.
s = [ 1, 2, 3, 4, 5 ].toSet();
doubled = s.map( ( Any v ) => v * 2 );
writeOutput( doubled.size() );
Result: 5
Map strings to uppercase
Result: true
Related
Last updated
Was this helpful?
