map (Function)

Signature: map(iterator: Iterator<t0>, fn: (t0) -> t1) -> Iterator<t1>

Description: Transforms each element in an iterator using a function, returning a new iterator.

Parameters

  • iterator (Iterator): The iterator to transform
  • fn ((t0) -> t1): The transformation function

Returns: Iterator

Example

let doubled = map(range(1, 4), fn(x) { x * 2 })
forEach(doubled, print)  // Prints: 2, 4, 6
doubled = map (range (1, 4), \x => x * 2)
forEach (doubled, print)  // Prints: 2, 4, 6