mirror of
https://github.com/GrammaticalFramework/gf-rgl.git
synced 2026-06-22 09:46:22 -06:00
The new Decimal API
This commit is contained in:
@@ -98,6 +98,11 @@ concrete CatMlt of Cat = CommonX - [Adv] ** open ResMlt, Prelude in {
|
||||
n : NumForm ;
|
||||
tail : DTail ;
|
||||
} ;
|
||||
Decimal = {
|
||||
s : NumCase => Str ; -- No need for CardOrd, i.e. no 1st, 2nd etc in Maltese
|
||||
n : NumForm ;
|
||||
hasDot : Bool ;
|
||||
} ;
|
||||
|
||||
-- Structural
|
||||
|
||||
|
||||
@@ -189,9 +189,7 @@ concrete NounMlt of Noun = CatMlt ** open ResMlt, Prelude, Maybe in {
|
||||
-- 51
|
||||
NumDigits d = {s = d.s ; n = d.n} ;
|
||||
|
||||
-- Digits -> Digits -> Card
|
||||
-- 3.14
|
||||
NumFloat d1 d2 = {s = \\c => d1.s ! NumNom ++ BIND ++ "." ++ BIND ++ d2.s ! c ; n = d1.n} ;
|
||||
NumDecimal d = {s = d.s ; n = d.n} ;
|
||||
|
||||
-- Digits -> Ord
|
||||
-- 51st
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
-- John J. Camilleri 2011 -- 2013
|
||||
-- Licensed under LGPL
|
||||
|
||||
concrete NumeralMlt of Numeral = CatMlt [Numeral,Digits] ** open Prelude,ResMlt in {
|
||||
concrete NumeralMlt of Numeral = CatMlt [Numeral,Digits,Decimal] ** open Prelude,ResMlt in {
|
||||
|
||||
flags coding=utf8 ;
|
||||
|
||||
@@ -437,4 +437,18 @@ concrete NumeralMlt of Numeral = CatMlt [Numeral,Digits] ** open Prelude,ResMlt
|
||||
tail = inc i.tail
|
||||
} ;
|
||||
|
||||
PosDecimal d = d ** {hasDot=False} ;
|
||||
NegDecimal d = {
|
||||
s = \\o => "-" ++ BIND ++ d.s ! o ;
|
||||
n = d.n ;
|
||||
hasDot=False
|
||||
} ;
|
||||
IFrac d i = {
|
||||
s=\\o=>d.s ! NumNom ++
|
||||
if_then_Str d.hasDot BIND (BIND++"."++BIND) ++
|
||||
i.s ! o;
|
||||
n = d.n;
|
||||
hasDot=True
|
||||
} ;
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user