-
-
Notifications
You must be signed in to change notification settings - Fork 804
/
Copy pathrepl.txt
65 lines (48 loc) · 1.77 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
{{alias}}( arr, initial, mapper, reducer[, thisArg] )
Performs a map-reduce operation for each element in an array and returns the
accumulated result.
When invoked, the mapping function is provided three arguments:
- value: array element.
- index: element index.
- arr: input array.
When invoked, the reducing function is provided four arguments:
- accumulator: accumulated value.
- value: result after applying the mapping function to the current array
element.
- index: element index.
- arr: input array.
If provided an empty array, the function returns the initial value.
When provided an ndarray, the function performs a single-pass map-reduce
operation over the entire input ndarray (i.e., higher-order ndarray
dimensions are flattened to a single-dimension).
Parameters
----------
arr: ArrayLikeObject|ndarray
Input array.
initial: any
Accumulator value used in the first invocation of the reduction
function.
mapper: Function
Mapping function.
reducer: Function
Reducing function.
thisArg: any (optional)
Execution context for the reducing function.
Returns
-------
out: any
Accumulated result.
Examples
--------
// array-like object:
> var f1 = {{alias:@stdlib/utils/nary-function}}( {{alias:@stdlib/math/base/special/abs}}, 1 );
> var f2 = {{alias:@stdlib/utils/nary-function}}( {{alias:@stdlib/number/float64/base/add}}, 2 );
> var arr = [ -1.0, -2.0, -3.0, -4.0, -5.0, -6.0 ];
> var out = {{alias}}( arr, 0.0, f1, f2 )
21.0
// ndarray:
> arr = {{alias:@stdlib/ndarray/array}}( arr, { 'shape': [ 2, 3 ] } );
> out = {{alias}}( arr, 0.0, f1, f2 )
21.0
See Also
--------