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
+2
View File
@@ -68,6 +68,8 @@ concrete CatGre of Cat = CommonGre ** open ResGre, Prelude in {
Numeral = {s : CardOrd => Str ; n : Number } ;
Digits = {s : CardOrd => Str ; n : Number} ;
Decimal = {s : CardOrd => Str ; n : Number ; hasDot : Bool} ;
-- Structural
+2 -1
View File
@@ -111,6 +111,7 @@ concrete NounGre of Noun = CatGre ** open ResGre, ParadigmsGre, Prelude in {
NumNumeral numeral = {s = \\g,c => numeral.s ! NCard g c; n = numeral.n } ;
NumDigits numeral = {s = \\g,c => numeral.s ! NCard g c; n = numeral.n } ;
NumDecimal numeral = {s = \\g,c => numeral.s ! NCard g c; n = numeral.n } ;
AdNum adn num = {s = \\g,c => adn.s ++ num.s!g!c; n = num.n } ;
@@ -244,4 +245,4 @@ concrete NounGre of Noun = CatGre ** open ResGre, ParadigmsGre, Prelude in {
}
}
+15 -1
View File
@@ -1,4 +1,4 @@
concrete NumeralGre of Numeral = CatGre [Numeral,Digits] ** open ResGre,Prelude in {
concrete NumeralGre of Numeral = CatGre [Numeral,Digits,Decimal] ** open ResGre,Prelude in {
flags coding= utf8 ;
@@ -291,6 +291,20 @@ Xilias : CardOrd -> (CardOrd => Str) -> Number -> Str = \co,d,n ->
D_8 = mk2Dig "8" Pl;
D_9 = mk2Dig "9" Pl ;
PosDecimal d = d ** {hasDot=False} ;
NegDecimal d = {
s = \\o => "-" ++ BIND ++ d.s ! o ;
n = Pl ;
hasDot=False
} ;
IFrac d i = {
s = \\o => d.s ! NCard Neut Nom ++
if_then_Str d.hasDot BIND (BIND++"."++BIND) ++
i.s ! o ;
n = Pl ;
hasDot=False
} ;
oper
mk3Dig : Str -> Number -> TDigit = \c,n -> {