Skip to content

Commit

Permalink
Better wording for array::reduce and fold (#1081)
Browse files Browse the repository at this point in the history
  • Loading branch information
Dhghomon authored Dec 20, 2024
1 parent 9e56ade commit 4e16f81
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/content/doc-surrealql/functions/database/array.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -830,7 +830,7 @@ RETURN array::flatten([ [1, 2], [3, 4], 'SurrealDB', [5, 6, [7, 8]] ]);

<Since v="v2.1.0" />

The `array::fold` function applies an operation on an initial value plus every element in the array, returning the final result. To use `array::fold`, pass in an initial value, followed by parameter names for the current value and the next value and an operation to perform on them. If you only want to perform an operation on each item and do not need an initial value, use the [`array::reduce`](/docs/surrealql/functions/database/array#arrayreduce) function.
The `array::fold` function returns a final value from the elements of an array by allowing an operation to be performed at each step of the way as each subsequent item in the array is encountered. To use `array::fold`, pass in an initial value, followed by parameter names for the current value and the next value and an operation to perform on them. If you only want to perform an operation on each item and do not need an initial value, use the [`array::reduce`](/docs/surrealql/functions/database/array#arrayreduce) function instead.

```surql title="API DEFINITION"
array::fold(array, initial_value, @closure) -> value
Expand Down Expand Up @@ -1420,7 +1420,7 @@ RETURN array::range(3, 2);

<Since v="v2.1.0" />

The `array::reduce` function applies an operation on every element in the array, returning the final result. To use `array::reduce`, pass in parameter names for the current value and the next value and an operation to perform on them. If you want to have an initial value to pass in before the other items are operated on, use the [`array::fold`](/docs/surrealql/functions/database/array#arrayfold) function.
The `array::reduce` function reduces the elements of an array to a single final value by allowing an operation to be performed at each step of the way as each subsequent item in the array is encountered. To use `array::reduce`, pass in parameter names for the current value and the next value and an operation to perform on them. If you need an initial value to pass in before the other items are operated on, use the [`array::fold`](/docs/surrealql/functions/database/array#arrayfold) function instead.

```surql title="API DEFINITION"
array::reduce(array, @closure) -> value
Expand Down

0 comments on commit 4e16f81

Please sign in to comment.