mirror of
https://github.com/GrammaticalFramework/gf-rgl.git
synced 2026-06-21 01:06:21 -06:00
The new Decimal API
This commit is contained in:
@@ -78,8 +78,7 @@ concrete CatKor of Cat = CommonX ** open ResKor, Prelude in {
|
||||
Card = ResKor.Num ;
|
||||
Numeral = ResKor.Numeral ;
|
||||
Digits = {s : CardOrd => Str ; n : Number} ;
|
||||
|
||||
|
||||
Decimal = {s : CardOrd => Str ; n : Number ; hasDot : Bool} ;
|
||||
|
||||
--2 Structural words
|
||||
|
||||
|
||||
@@ -107,9 +107,9 @@ concrete NounKor of Noun = CatKor ** open ResKor, Prelude in {
|
||||
numtype = IsDig
|
||||
} ;
|
||||
|
||||
NumFloat dig1 dig2 = baseNum ** {
|
||||
s = \\_,_ => dig1.s ! NCard ++ BIND ++ "." ++ BIND ++ dig2.s ! NCard ;
|
||||
n = Pl ;
|
||||
NumDecimal dec = baseNum ** {
|
||||
s = \\_,_ => dec.s ! NCard ;
|
||||
n = dec.n ;
|
||||
numtype = IsDig
|
||||
} ;
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
concrete NumeralKor of Numeral = CatKor [Numeral,Digits] **
|
||||
concrete NumeralKor of Numeral = CatKor [Numeral,Digits,Decimal] **
|
||||
open Prelude, ResKor in {
|
||||
|
||||
lincat
|
||||
@@ -154,6 +154,16 @@ lin
|
||||
D_7 = mkDig "7" ;
|
||||
D_8 = mkDig "8" ;
|
||||
D_9 = mkDig "9" ;
|
||||
|
||||
PosDecimal d = d ** {hasDot=False} ;
|
||||
NegDecimal d = {s=\\o=>"-" ++ BIND ++ d.s ! o; hasDot=False; n = Pl} ;
|
||||
IFrac d i = {
|
||||
s=\\o=>d.s ! NCard ++
|
||||
if_then_Str d.hasDot BIND (BIND++"."++BIND) ++
|
||||
i.s ! o ;
|
||||
hasDot=True;
|
||||
n = Pl
|
||||
} ;
|
||||
|
||||
oper
|
||||
mk2Dig : Str -> Str -> TDigit = \c,o -> mk3Dig c o numNumber ;
|
||||
|
||||
Reference in New Issue
Block a user