google / google/jsonnet

std.foldl1, std.foldr1

Open
#742 1 comment 0 reactions 0 assignees View on GitHub
stdlib
Dominant language
Jsonnet
Stars
7.6k
Forks
475
PR merge metrics
No merged PRs in 30d

Description

Fold variants which use first/last element as the starting value of the accumulator.

E.g. `sum(arr):: std.foldl1(function(x, y) x + y, arr)`.

In this case it's not hard to come up with a valid neutral element (0) and use the regular `fold`. But sometimes it can be awkward and/or inefficient.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.