The new Decimal API

This commit is contained in:
Krasimir Angelov
2023-08-21 20:14:26 +02:00
parent 58da8deca8
commit fb398c603e
147 changed files with 918 additions and 188 deletions

View File

@@ -64,7 +64,8 @@ concrete CatPes of Cat = CommonX ** open ResPes, Prelude in {
---- Numeral
Numeral = {s : CardOrd => Str ; n : Number} ;
Digits = {s : CardOrd => Str ; n : Number } ;
Digits = {s : CardOrd => Str ; n : Number} ;
Decimal = {s : CardOrd => Str ; n : Number; hasDot : Bool} ;
---- Structural

View File

@@ -97,6 +97,7 @@ concrete NounPes of Noun = CatPes ** open ResPes, Prelude in {
NumCard n = n ** {isNum = True} ;
NumDigits n = n ** {s = n.s ! NCard; isNum = True} ;
NumDecimal n = n ** {s = n.s ! NCard; isNum = True} ;
OrdDigits n = n ** {s = n.s ! NOrd ; isNum = True ; isPre=False} ;
NumNumeral n = n ** {s = n.s ! NCard; isNum = True} ;

View File

@@ -1,5 +1,5 @@
--# -path=.:../abstract:../common:
concrete NumeralPes of Numeral = CatPes [Numeral,Digits] ** open ResPes,Prelude in {
concrete NumeralPes of Numeral = CatPes [Numeral,Digits,Decimal] ** open ResPes,Prelude in {
flags coding = utf8;
@@ -83,7 +83,21 @@ lin pot3plus n m = {
D_9 = mkDig "9" ;
-- lin IDig d = { s = \\_ => d.s ; n = Sg} ;
lin IIDig d dg = { s = \\df => d.s ! NCard ++ dg.s ! df ; n = Pl};
IIDig d dg = { s = \\df => d.s ! NCard ++ dg.s ! df ; n = Pl};
PosDecimal d = d ** {hasDot=False} ;
NegDecimal d = {
s = \\df => "-" ++ d.s ! df ;
n = Pl ;
hasDot=False
};
IFrac d i = {
s=\\df=>d.s ! NCard ++
if_then_Str d.hasDot BIND (BIND++"."++BIND) ++
i.s ! df;
n = Pl;
hasDot=True
} ;
oper
commaIf : DTail -> Str = \t -> case t of {