/ test / contracts / sophia_2 / test.aes
test.aes
  1  
  2  contract Identity =
  3    // type xy = {x:int, y:int}
  4    // type xz = {x:int, z:int}
  5    // type yz = {y:int, z:int}
  6    record point = {x:int,y:int}
  7    record cp('a) = {color: string, p:'a}
  8    //type intpoint = point(int)
  9    //   //if (x==42) 1 else (x*x)
 10    // }
 11    //let baz() = {age:3, name:(4:int)}
 12    //let foo(a,b,c) = c
 13    // let rec fac(n) = if((n:int)==0) 1 else (n*fac(n-1))
 14    //    and main_(x) = x::[x+1]
 15    // let lentr(l) = lent(0,l)
 16    // let rec len(l) =
 17    //    switch(l) {
 18    //     | [] => 0
 19    //     | x::xs => 1+len(xs)
 20    //     }
 21    // let lent(n,l) =
 22    //   switch (l) {
 23    //   | [] => n
 24    //   | (x::xs) => lent(n+1,xs)
 25    //   }
 26    //  let rec app(a,b) =
 27    //     switch(a) {
 28    //     | [] => b
 29    //     | (x::xs) => x::app(xs,b)
 30    //     }
 31    // let rec revt(l,r) =
 32    //   switch(l) {
 33    //   | [] => r
 34    //   | x::xs => revt(xs,x::r)
 35    //   }
 36    // let rev(l) = revt(l,[])
 37    // let main_(x:int) = {
 38    //   switch(rev([1,2,3])) {
 39    //   | h::_ => h
 40    //   }
 41    //   }
 42    //let fac(n:int) = {
 43    //  if (n==0) 1 else (n*fac(n-1))
 44    //}
 45    //let main_(x) = switch((12,34)) {
 46    //| (13,_) => x
 47    //| (_,a) => x+a
 48    //    | y => y+1
 49    //  }
 50    //let main_(x) = ({y:0>1, x:x==0}:point(bool))
 51    //let main_(x) = x
 52    //let main_(x) = len(1::2::[])
 53    //let main_(x) = ((x,x):list('a))
 54    // let main_(x) = switch("a") {
 55    //    	  |  "b" => 0
 56    // 	  |  "a" => 1
 57    // 	  |  "c" => 2
 58    // 	  }
 59    //let main_(x) = x.color+1
 60    //let main_(x) = switch(({x:x, y:x+1}:cp(int))) {
 61    //              | {y:xx} => xx
 62    //		}
 63    //let main_(x) = {x:0, y:1, z:2}
 64    // let id(x) = x
 65    // let double(x) = x+x
 66    // let pair(x) = (1,2)
 67    // let unit(x) = ()
 68    // let tuples(x) = ((1,x),(2,3,4))
 69    // let singleton(x) = [x]
 70    // let rec seq(n) = if (n==0) [] else (app(seq(n-1),[n]))
 71    // let idString(s:string) = s
 72    // let pairString(s:string) = (s,s)
 73    // let revStrings(ss:list(string))=rev(ss)
 74    // let makePoint(x,y) = {x:x, y:y}
 75    // let getx(x) = x.x
 76    // let updatex(p,x) = p{x:x}
 77    // let quad(x) = {let y=x+x; let z=y+y; z;}
 78   //  let noblock(x) = {x; x}
 79   //  let unit(x) = ()
 80    // let foo(x) = switch (x) {
 81    //     	       | y => y+1
 82  // 	       }
 83    // let p(x) = {color:"blue", p:{x:x, y:x+1}}
 84    //let twice(f,x) = f(f(x))
 85    // let twice(f,x) = f(f(x))
 86    // let double(x) = x+x
 87    // let main_(x) = twice((y=>y+y),x)
 88    // let rec map(f,xs) = switch(xs) {
 89    // | [] => []
 90    // | (x::ys) => f(x)::map(f,ys)
 91    // }
 92    // let id(x) = x
 93    // let main_(xs) = map(double,xs)
 94    function z(f,x) = x
 95    private function s(n) = (f,x)=>f(n(f,x))
 96    private function add(m,n) = (f,x)=>m(f,n(f,x))
 97    function main_(_) =
 98      let three=s(s(s(z)))
 99      add(three,three)
100         (((i)=>i+1),0)
101