Apply a callback to an array

From Fōrmulæ wiki
Jump to: navigation, search

This page is the answer to the task Apply a callback to an array in the Rosetta Code.

Description (from Rosetta Code)

Task

Take a combined set of elements and apply a function to each element.

Solution

The next expression squares the elements of an array. The resulting array is a new one, the original one is not changed.

CallbackArray.png

The elements do not need to be strictly numbers:

CallbackArray2.png