mirror of
https://github.com/GrammaticalFramework/gf-rgl.git
synced 2026-06-12 00:20:11 -06:00
The new Decimal API
This commit is contained in:
@@ -85,6 +85,7 @@ concrete CatEus of Cat = CommonX ** open ResEus, Prelude in {
|
||||
|
||||
Numeral = { s : Str ; n : Number } ;
|
||||
Digits = { s : CardOrd => Str ; n : Number } ;
|
||||
Decimal = { s : CardOrd => Str ; n : Number ; hasDot : Bool} ;
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -125,6 +125,7 @@ concrete NounEus of Noun = CatEus ** open ResEus, Prelude in {
|
||||
|
||||
-- : Digits -> Card ;
|
||||
NumDigits dig = { s = dig.s ! NCard ; n = dig.n } ;
|
||||
NumDecimal dec = { s = dec.s ! NCard ; n = dec.n } ;
|
||||
|
||||
-- : Numeral -> Card ;
|
||||
NumNumeral num = num ;
|
||||
@@ -260,4 +261,4 @@ concrete NounEus of Noun = CatEus ** open ResEus, Prelude in {
|
||||
oper
|
||||
elative : NP -> Str = \np -> glue (np.s ! LocStem) "rik" ;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
concrete NumeralEus of Numeral = CatEus [Numeral,Digits] ** open Prelude, ResEus, ParamX in {
|
||||
concrete NumeralEus of Numeral = CatEus [Numeral,Digits,Decimal] ** open Prelude, ResEus, ParamX in {
|
||||
|
||||
oper LinDigit : Type = { s : DForm => Str ;
|
||||
n : Number ;
|
||||
@@ -112,5 +112,18 @@ lin D_9 = mkDig "9" ;
|
||||
lin IDig dig = dig ;
|
||||
-- : Dig -> Digits -> Digits ;
|
||||
lin IIDig dig digs = digs ** {s = \\co => glue (dig.s ! co) (digs.s ! co) } ;
|
||||
lin PosDecimal d = d ** {hasDot=False} ;
|
||||
lin NegDecimal d = {
|
||||
s = \\co => glue "-" (d.s ! co) ;
|
||||
n = Pl ;
|
||||
hasDot=False
|
||||
} ;
|
||||
lin IFrac d i = {
|
||||
s = \\co => d.s ! co ++
|
||||
if_then_Str d.hasDot BIND (BIND++"."++BIND) ++
|
||||
i.s ! co ;
|
||||
n = Pl ;
|
||||
hasDot=False
|
||||
} ;
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user