Skip to content

Commit 133ba24

Browse files
andrew-colemanmattbaileyuk
authored andcommitted
update docs for $reduce function
1 parent 497c602 commit 133ba24

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

docs/higher-order-functions.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ The function that is supplied as the second parameter must have the following si
4747

4848
Each value in the input array is passed in as the first parameter in the supplied function. The index (position) of that value in the input array is passed in as the second parameter, if specified. The whole input array is passed in as the third parameter, if specified.
4949

50-
__Example__
50+
__Example__
5151
The following expression returns all the products whose price is higher than average:
5252
```
5353
$filter(Account.Order.Product, function($v, $i, $a) {
@@ -66,7 +66,7 @@ The function that is supplied as the second parameter must have the following si
6666

6767
Each value in the input array is passed in as the first parameter in the supplied function. The index (position) of that value in the input array is passed in as the second parameter, if specified. The whole input array is passed in as the third parameter, if specified.
6868

69-
__Example__
69+
__Example__
7070
The following expression the product in the order whose SKU is `"0406654608"`:
7171
```
7272
$single(Account.Order.Product, function($v, $i, $a) {
@@ -79,7 +79,9 @@ __Signature:__ `$reduce(array, function [, init])`
7979

8080
Returns an aggregated value derived from applying the `function` parameter successively to each value in `array` in combination with the result of the previous application of the function.
8181

82-
The function must accept two arguments, and behaves like an infix operator between each value within the `array`.
82+
The `function` must accept at least two arguments, and behaves like an infix operator between each value within the `array`. The signature of this supplied function must be of the form:
83+
84+
`myfunc($accumulator, $value[, $index[, $array]])`
8385

8486
__Example__
8587

0 commit comments

Comments
 (0)