Skip to main content

Vector.map

mapfunctionon_problems

Documentation

Applies a function to each element of the vector, returning the Vector of results.

Arguments

  • function: A function that takes an element in the vector and returns some transformation of that element.
  • on_problems: Specifies how to handle any problems that arise in function.

Examples

Add 1 to each element of the vector.

      [1, 2, 3] . map +1

Errors

The result of Errors thrown when executing the function depend on on_problems:

  • Report_Error: The first error is thrown, and is wrapped in Map_Error.
  • No_Wrap: The first error is thrown, and is not wrapped in Map_Error.
  • Report_Warning: The result for that element is Nothing, the error is attached as a warning. Currently unimplemented.
  • Ignore: The result is Nothing, and the error is ignored.

Errors that are thrown when executing the supplied function are wrapped in Map_Error, which contains the index at which the error occurred.

In the Report_Warning case, only MAX_MAP_WARNINGS warnings are attached to result values. After that, the warnings are dropped, but a count of the additional warnings is attached in an Additional_Warnings warning.