Skip to content

Commit

Permalink
doc: primops: add more info for foldl
Browse files Browse the repository at this point in the history
From the existing doc it is not obvious whether the first or the
second argument is the accumulator. This is however relevant to
know, as for certain scenarios, this might change the behavior.
  • Loading branch information
phip1611 committed Oct 29, 2023
1 parent a6e5879 commit 22e0889
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/libexpr/primops.cc
Original file line number Diff line number Diff line change
Expand Up @@ -3182,7 +3182,9 @@ static RegisterPrimOp primop_foldlStrict({
e.g. `foldl' op nul [x0 x1 x2 ...] = op (op (op nul x0) x1) x2)
...`. For example, `foldl' (x: y: x + y) 0 [1 2 3]` evaluates to 6.
The return value of each application of `op` is evaluated immediately,
even for intermediate values.
even for intermediate values. The first argument of the operation
(`x` in the example above) is the accumulator wheres the second one
(`y`) is the next element.
)",
.fun = prim_foldlStrict,
});
Expand Down

0 comments on commit 22e0889

Please sign in to comment.