mirror of
https://github.com/GrammaticalFramework/gf-rgl.git
synced 2026-06-16 10:30:11 -06:00
The new Decimal API
This commit is contained in:
@@ -55,6 +55,7 @@ concrete CatIna of Cat = CommonX ** open ResIna, Prelude in {
|
||||
|
||||
Numeral = {s : CardOrd => Str ; n : Number} ;
|
||||
Digits = {s : CardOrd => Str ; n : Number ; tail : DTail} ;
|
||||
Decimal = {s : CardOrd => Str ; n : Number ; hasDot : Bool} ;
|
||||
|
||||
-- Structural
|
||||
|
||||
|
||||
@@ -61,6 +61,7 @@ concrete NounIna of Noun = CatIna ** open ResIna, Prelude in {
|
||||
NumCard c = c ;
|
||||
|
||||
NumDigits n = {s = n.s ! NCard ; n = n.n} ;
|
||||
NumDecimal n = {s = n.s ! NCard ; n = n.n} ;
|
||||
|
||||
OrdDigits n = {s = n.s ! NOrd} ;
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
concrete NumeralIna of Numeral = CatIna [Numeral,Digits] ** open ResIna,Prelude in {
|
||||
concrete NumeralIna of Numeral = CatIna [Numeral,Digits,Decimal] ** open ResIna,Prelude in {
|
||||
|
||||
lincat
|
||||
Digit = {s : DForm => CardOrd => Str} ;
|
||||
@@ -66,6 +66,20 @@ concrete NumeralIna of Numeral = CatIna [Numeral,Digits] ** open ResIna,Prelude
|
||||
D_8 = mkDig "8" ;
|
||||
D_9 = mkDig "9" ;
|
||||
|
||||
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 ++
|
||||
if_then_Str d.hasDot BIND (BIND++"."++BIND) ++
|
||||
i.s ! o;
|
||||
n = Pl ;
|
||||
hasDot=True
|
||||
} ;
|
||||
|
||||
oper
|
||||
commaIf : DTail -> Str = \t -> case t of {
|
||||
T3 => BIND++","++BIND ;
|
||||
|
||||
Reference in New Issue
Block a user