UNPKG

878 BMarkdownView Raw
1<!-- Note: This file is automatically generated from source code comments. Changes made in this file will be overridden. -->
2
3# Function map
4
5Create a new matrix or array with the results of the callback function executed on
6each entry of the matrix/array.
7
8
9## Syntax
10
11```js
12math.map(x, callback)
13```
14
15### Parameters
16
17Parameter | Type | Description
18--------- | ---- | -----------
19`x` | Matrix &#124; Array | The matrix to iterate on.
20`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.
21
22### Returns
23
24Type | Description
25---- | -----------
26Matrix &#124; array | Transformed map of x
27
28
29## Examples
30
31```js
32math.map([1, 2, 3], function(value) {
33 return value * value
34}) // returns [1, 4, 9]
35```
36
37
38## See also
39
40[filter](filter.md),
41[forEach](forEach.md),
42[sort](sort.md)