-
-
Notifications
You must be signed in to change notification settings - Fork 804
/
Copy pathrepl.txt
106 lines (80 loc) · 2.69 KB
/
repl.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
{{alias}}( arr, fcn[, thisArg] )
Applies a function to each element in an array and assigns the result to an
element in a new array.
The applied function is provided the following arguments:
- value: array element.
- index: element index.
- arr: input array.
The returned output array always has a "generic" data type. For example, if
provided an array-like object, the function returns a generic array. If
provided an ndarray, the function returns an ndarray having a "generic" data
type.
Parameters
----------
arr: ArrayLikeObject|ndarray
Input array.
fcn: Function
Function to apply.
thisArg: any (optional)
Input function context.
Returns
-------
out: Array|ndarray
Output array.
Examples
--------
// array-like object:
> var f = {{alias:@stdlib/utils/nary-function}}( {{alias:@stdlib/math/base/special/abs}}, 1 );
> var arr = [ -1, -2, -3, -4, -5, -6 ];
> var out = {{alias}}( arr, f )
[ 1, 2, 3, 4, 5, 6 ]
// ndarray:
> arr = {{alias:@stdlib/ndarray/array}}( arr, { 'shape': [ 2, 3 ] } );
> out = {{alias}}( arr, f );
> var v = out.get( 1, 1 )
5
{{alias}}.assign( arr, out, fcn[, thisArg] )
Applies a function to each element in an array and assigns the result to an
element in an output array.
The applied function is provided the following arguments:
- value: array element.
- index: element index.
- arr: input array.
Input and output arrays must be either both array-like objects or both
ndarray-like objects.
If input and output arrays are array-like objects, the arrays must have the
same number of elements.
If input and output arrays are both ndarray-like objects, the arrays *must*
be broadcast compatible.
Parameters
----------
arr: ArrayLikeObject|ndarray
Input array.
out: ArrayLikeObject|ndarray
Output array.
fcn: Function
Function to apply.
thisArg: any (optional)
Input function context.
Returns
-------
out: Array|ndarray
Output array.
Examples
--------
// array-like object:
> var f = {{alias:@stdlib/utils/nary-function}}( {{alias:@stdlib/math/base/special/abs}}, 1 );
> var arr = [ -1, -2, -3, -4, -5, -6 ];
> var out = [ 0, 0, 0, 0, 0, 0 ];
> {{alias}}.assign( arr, out, f );
> out
[ 1, 2, 3, 4, 5, 6 ]
// ndarray:
> var opts = { 'shape': [ 2, 3 ] };
> arr = {{alias:@stdlib/ndarray/array}}( arr, opts );
> out = {{alias:@stdlib/ndarray/array}}( [ 0, 0, 0, 0, 0, 0 ], opts );
> {{alias}}.assign( arr, out, f );
> var v = out.get( 1, 1 )
5
See Also
--------