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

@@ -80,6 +80,7 @@ concrete CatMay of Cat = CommonX - [IAdv] ** open ResMay, Prelude in {
Card = ResMay.CardNum ;
Numeral = ResMay.CardOrdNum ;
Digits = ResMay.DigNum ;
Decimal = ResMay.DigNum**{hasDot : Bool} ;
@@ -132,4 +133,4 @@ concrete CatMay of Cat = CommonX - [IAdv] ** open ResMay, Prelude in {
-- Determiner : Type = Quant ** {
-- pr : Str ; -- prefix for numbers
-- n : NumType ; -- number as in 5 (noun in singular), Sg or Pl
-- } ;
-- } ;

View File

@@ -101,6 +101,10 @@ concrete NounMay of Noun = CatMay ** open ResMay, Prelude in {
s = dig.s ! NCard
} ;
NumDecimal dec = {
s = dec.s ! NCard
} ;
-- : Numeral -> Card ;
NumNumeral num = num ;

View File

@@ -1,6 +1,6 @@
-- David Wahlstedt 2002 (cardinal numbers)
-- Inari Listenmaa 2020 (ordinals + cosmetic changes)
concrete NumeralMay of Numeral = CatMay [Numeral,Digits] **
concrete NumeralMay of Numeral = CatMay [Numeral,Digits,Decimal] **
open Prelude, ResMay in {
lincat
@@ -151,6 +151,16 @@ oper
D_8 = mkDig "8" ;
D_9 = mkDig "9" ;
PosDecimal d = d ** {hasDot=False} ;
NegDecimal d = {s=\\o=>"-" ++ BIND ++ d.s ! o; hasDot=False} ;
IFrac d i = {
s=\\o=>d.s ! NCard ++
if_then_Str d.hasDot BIND (BIND++"."++BIND) ++
i.s ! o ;
hasDot=True;
n = Pl
} ;
oper
mkDig : Str -> DigNum = \s -> {
s = table {