2014-07-03 16:09:04 +02:00

1.1 KiB

layout
default

Function map #

Create a new matrix or array with the results of the callback function executed on each entry of the matrix/array.

Syntax #

math.map(x, callback)

Parameters #

Parameter Type Description
x Matrix | Array The matrix to iterate on.
callback Function The callback method is invoked with three parameters: the value of the element, the index of the element, and the matrix being traversed.

Returns #

Type Description
Matrix | array Transformed map of x

Examples #

math.map([1, 2, 3], function(value) {
  return value * value;
});  // returns [1, 4, 9]