dhall-nix-lib/Natural/listMin.dhall

19 lines
478 B
Text

λ(nix : ../NixPrelude.dhall) →
let min = ./min.dhall
let Optional/map = ../Optional/map.dhall nix
let listMin
: List Natural → Optional Natural
= λ(xs : List Natural) →
Optional/map
Natural
Natural
( λ(n : Natural) →
if Natural/isZero n
then n
else List/fold Natural xs Natural min n
)
(List/head Natural xs)
in listMin