home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 4 / Apprentice-Release4.iso / Languages / Caml Light 0.7 / examples / asl / example.res < prev    next >
Encoding:
Text File  |  1995-06-01  |  1.3 KB  |  73 lines  |  [TEXT/MPS ]

  1. >> 1;
  2.    it : Number
  3.    it = Numval 1
  4.  
  5. >> + 2 ((\x.x) 3);
  6.    it : Number
  7.    it = Numval 5
  8.  
  9. >> if + 0 1 then 1 else 0 fi;
  10.    it : Number
  11.    it = Numval 1
  12.  
  13. >> let f = \x. + x 1;
  14.    f : (Number -> Number)
  15.    f = Funval <fun>
  16.  
  17. >> let I = \x. x;
  18.    I : ('a -> 'a)
  19.    I = Funval <fun>
  20.  
  21. >> let x = I (f 2);
  22.    x : Number
  23.    x = Numval 3
  24.  
  25. >> let g = \x.x 1;
  26.    g : ((Number -> 'a) -> 'a)
  27.    g = Funval <fun>
  28.  
  29. >> + (I 1) (I I 2);
  30.    it : Number
  31.    it = Numval 3
  32.  
  33. >> (\x.x x) (\x.x);
  34.    it : ('a -> 'a)
  35.    it = Funval <fun>
  36.  
  37. >> (if x then (\x.x) else 2 fi) 0;
  38. *** ASL Type clash between ('a -> 'a) and Number
  39. *** Failed: ASL typing
  40.  
  41. >> let Z = \f. (\x.f(\y.x x y)) (\x.f(\y.x x y));
  42. *** ASL Type clash between 'a and ('a -> 'b)
  43. *** Failed: ASL typing
  44.  
  45. >> let Z = \f. (\V.V (magic V)) (\x.f(\y.magic x x y));
  46.    Z : ((('a -> 'b) -> 'c) -> 'c)
  47.    Z = Funval <fun>
  48.  
  49. >> let fact = Z (\fact.\n. if = n 0 then 1 else * n (fact (- n 1)) fi);
  50.    fact : (Number -> Number)
  51.    fact = Funval <fun>
  52.  
  53. >> fact 8;
  54.    it : Number
  55.    it = Numval 40320
  56.  
  57. >> let fib = Z (\fib.\n.
  58. >>   if = n 1 then 1
  59. >>   else if = n 2 then 1 else + (fib(- n 1)) (fib(- n 2)) fi fi
  60. >> );
  61.    fib : (Number -> Number)
  62.    fib = Funval <fun>
  63.  
  64. >> fib 9;
  65.    it : Number
  66.    it = Numval 34
  67.  
  68. >> + (\x.x) 1;
  69. *** ASL Type clash between Number and ('a -> 'a)
  70. *** Failed: ASL typing
  71.  
  72. >> 
  73.