dhall-nix-lib/Integer/listMin.dhall

21 lines
517 B
Text

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