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

@@ -78,8 +78,7 @@ concrete CatKor of Cat = CommonX ** open ResKor, Prelude in {
Card = ResKor.Num ;
Numeral = ResKor.Numeral ;
Digits = {s : CardOrd => Str ; n : Number} ;
Decimal = {s : CardOrd => Str ; n : Number ; hasDot : Bool} ;
--2 Structural words

View File

@@ -107,9 +107,9 @@ concrete NounKor of Noun = CatKor ** open ResKor, Prelude in {
numtype = IsDig
} ;
NumFloat dig1 dig2 = baseNum ** {
s = \\_,_ => dig1.s ! NCard ++ BIND ++ "." ++ BIND ++ dig2.s ! NCard ;
n = Pl ;
NumDecimal dec = baseNum ** {
s = \\_,_ => dec.s ! NCard ;
n = dec.n ;
numtype = IsDig
} ;

View File

@@ -1,4 +1,4 @@
concrete NumeralKor of Numeral = CatKor [Numeral,Digits] **
concrete NumeralKor of Numeral = CatKor [Numeral,Digits,Decimal] **
open Prelude, ResKor in {
lincat
@@ -154,6 +154,16 @@ lin
D_7 = mkDig "7" ;
D_8 = mkDig "8" ;
D_9 = mkDig "9" ;
PosDecimal d = d ** {hasDot=False} ;
NegDecimal d = {s=\\o=>"-" ++ BIND ++ d.s ! o; hasDot=False; n = Pl} ;
IFrac d i = {
s=\\o=>d.s ! NCard ++
if_then_Str d.hasDot BIND (BIND++"."++BIND) ++
i.s ! o ;
hasDot=True;
n = Pl
} ;
oper
mk2Dig : Str -> Str -> TDigit = \c,o -> mk3Dig c o numNumber ;