1
1
mirror of https://github.com/tweag/nickel.git synced 2024-09-20 08:05:15 +03:00

Fixes in the nums stdlib

This commit is contained in:
Yann Hamdaoui 2021-03-11 11:11:18 +01:00
parent b23df115a1
commit 16b02c60c7

View File

@ -18,12 +18,12 @@
else
%blame% (%tag% "not a number" label);
PosInt = fun label value =>
PosNat = fun label value =>
if %isNum% value then
if value % 1 == 0 && value > 0 then
value
else
%blame% (%tag% "not a positive integer" label)
%blame% (%tag% "not positive integer" label)
else
%blame% (%tag% "not a number" label);
@ -36,6 +36,9 @@
else
%blame% (%tag% "not a number" label);
isInt : Num -> Bool = fun x =>
%isNum% x && (x % 1 == 0);
min : Num -> Num -> Num = fun x y =>
if x <= y then x else y;
@ -43,22 +46,19 @@
if x >= y then x else y;
floor : Num -> Num = fun x =>
x - 1 + (x % 1);
if x >= 0 then x - (x % 1)
else x - 1 - (x % 1);
abs : Num -> Num = fun x =>
if x < 0 then -x else x;
frac : Num -> Num = fun x =>
fract : Num -> Num = fun x =>
x % 1;
trunc : Num -> Num = fun x =>
if x > 0 then x - (x % 1)
else x + (x % 1);
x - (x % 1);
pow : Num -> Num -> Num = fun x n =>
%pow% x n;
isInt : Num -> Bool => fun x =>
%isNum% x && (x % 1 == 0)
}
}