mirror of
https://github.com/GrammaticalFramework/gf-rgl.git
synced 2026-06-20 16:56:18 -06:00
The new Decimal API
This commit is contained in:
@@ -64,7 +64,8 @@ concrete CatPes of Cat = CommonX ** open ResPes, Prelude in {
|
||||
---- Numeral
|
||||
|
||||
Numeral = {s : CardOrd => Str ; n : Number} ;
|
||||
Digits = {s : CardOrd => Str ; n : Number } ;
|
||||
Digits = {s : CardOrd => Str ; n : Number} ;
|
||||
Decimal = {s : CardOrd => Str ; n : Number; hasDot : Bool} ;
|
||||
|
||||
---- Structural
|
||||
|
||||
|
||||
@@ -97,6 +97,7 @@ concrete NounPes of Noun = CatPes ** open ResPes, Prelude in {
|
||||
NumCard n = n ** {isNum = True} ;
|
||||
|
||||
NumDigits n = n ** {s = n.s ! NCard; isNum = True} ;
|
||||
NumDecimal n = n ** {s = n.s ! NCard; isNum = True} ;
|
||||
OrdDigits n = n ** {s = n.s ! NOrd ; isNum = True ; isPre=False} ;
|
||||
|
||||
NumNumeral n = n ** {s = n.s ! NCard; isNum = True} ;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
--# -path=.:../abstract:../common:
|
||||
concrete NumeralPes of Numeral = CatPes [Numeral,Digits] ** open ResPes,Prelude in {
|
||||
concrete NumeralPes of Numeral = CatPes [Numeral,Digits,Decimal] ** open ResPes,Prelude in {
|
||||
|
||||
flags coding = utf8;
|
||||
|
||||
@@ -83,7 +83,21 @@ lin pot3plus n m = {
|
||||
D_9 = mkDig "9" ;
|
||||
|
||||
-- lin IDig d = { s = \\_ => d.s ; n = Sg} ;
|
||||
lin IIDig d dg = { s = \\df => d.s ! NCard ++ dg.s ! df ; n = Pl};
|
||||
IIDig d dg = { s = \\df => d.s ! NCard ++ dg.s ! df ; n = Pl};
|
||||
|
||||
PosDecimal d = d ** {hasDot=False} ;
|
||||
NegDecimal d = {
|
||||
s = \\df => "-" ++ d.s ! df ;
|
||||
n = Pl ;
|
||||
hasDot=False
|
||||
};
|
||||
IFrac d i = {
|
||||
s=\\df=>d.s ! NCard ++
|
||||
if_then_Str d.hasDot BIND (BIND++"."++BIND) ++
|
||||
i.s ! df;
|
||||
n = Pl;
|
||||
hasDot=True
|
||||
} ;
|
||||
|
||||
oper
|
||||
commaIf : DTail -> Str = \t -> case t of {
|
||||
|
||||
Reference in New Issue
Block a user