mirror of
https://github.com/GrammaticalFramework/gf-rgl.git
synced 2026-06-22 17:56:21 -06:00
The new Decimal API
This commit is contained in:
@@ -75,6 +75,7 @@ concrete CatLit of Cat = CommonX - [CAdv, Adv] ** open ResLit, Prelude, (R = Par
|
||||
numAgr:NumComb; nb:Number };
|
||||
Ord = { s:AForm => Str };
|
||||
Digits = { s:Str; o:Str; numAgr:NumComb; nb:Number };
|
||||
Decimal = { s:Str; o:Str; numAgr:NumComb; nb:Number; hasDot : Bool };
|
||||
|
||||
|
||||
---- Structural
|
||||
|
||||
@@ -249,6 +249,7 @@ concrete NounLit of Noun = CatLit ** open ResLit, Prelude, MorphoLit, Predef in
|
||||
|
||||
-- NumDigits : Digits -> Card ; -- 51
|
||||
NumDigits n = { s=\\_,_ => n.s; numAgr=n.numAgr; nb=n.nb };
|
||||
NumDecimal n = { s=\\_,_ => n.s; numAgr=n.numAgr; nb=n.nb };
|
||||
|
||||
-- NumCard : Card -> Num ;
|
||||
NumCard c = c ** { hasCard = True };
|
||||
|
||||
@@ -345,4 +345,21 @@ oper simtas : Case * Number => Str
|
||||
D_8 = { s = "8"; o="8."; nb=Pl; numAgr=AgrComb };
|
||||
D_9 = { s = "9"; o="9."; nb=Pl; numAgr=AgrComb };
|
||||
|
||||
PosDecimal d = d ** {hasDot=False} ;
|
||||
NegDecimal d = {
|
||||
s = "-" ++ BIND ++ d.s;
|
||||
o = "-" ++ BIND ++ d.o;
|
||||
nb=Pl;
|
||||
numAgr=d.numAgr;
|
||||
hasDot=False
|
||||
} ;
|
||||
IFrac d i = {
|
||||
s = d.s ++
|
||||
if_then_Str d.hasDot BIND (BIND++"."++BIND) ++
|
||||
i.s;
|
||||
nb = Pl ;
|
||||
numAgr=d.numAgr;
|
||||
hasDot=True
|
||||
} ;
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user