map

map(x, callback)

map(x, y, ..., callback)

Try it yourself:

See also:

map(): Applying a Function to Each Value

map() applies a function or expression to every entry in a collection, returning a transformed collection of the same general shape. It is useful for conversions, cleanup, and element-by-element mathematical transformations.

Element-wise intent

For example, map can square each entry or convert every measurement. Use dotPow() when a standard element-wise power is enough, and dotMultiply() for matching weights. map is clearer when the per-entry logic is custom.

Ensure the mapping operation accepts every possible entry, including zero, negative, or missing-like values. Use filter() first to remove unsuitable entries, and verify output shape with size().

Try Map in Calcul.io

Start with one of the editable examples above, then replace its arguments with your own values. Keeping the function on a separate calculator line makes the input and result easy to compare. For a longer workflow, assign the result to a variable or reference that line in the next expression.

Check the shown signature before adding optional arguments, and use the related-function links to compare operations with similar purposes.

All functions