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

@@ -85,6 +85,7 @@ concrete CatEus of Cat = CommonX ** open ResEus, Prelude in {
Numeral = { s : Str ; n : Number } ;
Digits = { s : CardOrd => Str ; n : Number } ;
Decimal = { s : CardOrd => Str ; n : Number ; hasDot : Bool} ;

View File

@@ -125,6 +125,7 @@ concrete NounEus of Noun = CatEus ** open ResEus, Prelude in {
-- : Digits -> Card ;
NumDigits dig = { s = dig.s ! NCard ; n = dig.n } ;
NumDecimal dec = { s = dec.s ! NCard ; n = dec.n } ;
-- : Numeral -> Card ;
NumNumeral num = num ;
@@ -260,4 +261,4 @@ concrete NounEus of Noun = CatEus ** open ResEus, Prelude in {
oper
elative : NP -> Str = \np -> glue (np.s ! LocStem) "rik" ;
}
}

View File

@@ -1,4 +1,4 @@
concrete NumeralEus of Numeral = CatEus [Numeral,Digits] ** open Prelude, ResEus, ParamX in {
concrete NumeralEus of Numeral = CatEus [Numeral,Digits,Decimal] ** open Prelude, ResEus, ParamX in {
oper LinDigit : Type = { s : DForm => Str ;
n : Number ;
@@ -112,5 +112,18 @@ lin D_9 = mkDig "9" ;
lin IDig dig = dig ;
-- : Dig -> Digits -> Digits ;
lin IIDig dig digs = digs ** {s = \\co => glue (dig.s ! co) (digs.s ! co) } ;
lin PosDecimal d = d ** {hasDot=False} ;
lin NegDecimal d = {
s = \\co => glue "-" (d.s ! co) ;
n = Pl ;
hasDot=False
} ;
lin IFrac d i = {
s = \\co => d.s ! co ++
if_then_Str d.hasDot BIND (BIND++"."++BIND) ++
i.s ! co ;
n = Pl ;
hasDot=False
} ;
}