ansible/dhall/Prelude/Natural/sum.dhall
2024-11-26 00:55:56 -05:00

11 lines
304 B
Text

--| Add all the numbers in a `List`
let sum
: List Natural → Natural
= λ(xs : List Natural) →
List/fold Natural xs Natural (λ(l : Natural) → λ(r : Natural) → l + r) 0
let example = assert : sum [ 2, 3, 5 ] ≡ 10
let example = assert : sum ([] : List Natural) ≡ 0
in sum