dhall-nix-lib/Number/abs.dhall

14 lines
295 B
Text

λ(nix : ../NixPrelude.dhall) →
let Number = ./Type.dhall
let isZero = ./isZero.dhall nix
let clamp = ./clamp.dhall nix
let negate = ./negate.dhall nix
let abs
: Number → Number
= λ(n : Number) → if isZero (clamp n) then clamp (negate n) else clamp n
in abs