summaryrefslogtreecommitdiff
path: root/examples/jem-math/MathEng.gf
blob: ac29a504e16842eaa930361acb71a983a301366e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
concrete MathEng of Math = {

lincat 
  Prop, Exp = Str ;

lin
  And a b = a ++ "and" ++ b ;
  Or a b = a ++ "or" ++ b ;
  If a b = "if" ++ a ++ "then" ++ b ;

  Zero = "zero" ;

  X = "x" ;
  Y = "y" ;

  Successor x = "the successor of" ++ x ;

  Sum x y = "the sum of" ++ x ++ "and" ++ y ;
  Product x y = "the product of" ++ x ++ "and" ++ y ;

  Even x = x ++ "is even" ;
  Odd x = x ++ "is odd" ;
  Prime x = x ++ "is prime" ;
  
  Equal x y = x ++ "is equal to" ++ y ;
  Less x y = x ++ "is less than" ++ y ; 
  Greater x y = x ++ "is greater than" ++ y ; 
  Divisible x y = x ++ "is divisible by" ++ y ; 

lincat 
  Var = Str ;
lin
  X = "x" ;
  Y = "y" ;

  EVar x = x ;
  EInt i = i.s ;

  ANumberVar x = "a number" ++ x ;
  TheNumberVar x = "the number" ++ x ;

}