About LML The following Oz code is derived from the examples provided in the book:
      "The Little MLer" by Matthias Felleisen and Daniel P. Friedman.
      http://www.ccs.neu.edu/home/matthias/BTML/

Chapter #7 Examples in Oz
% Defined in previous chapters
fun {EqInt X Y} X == Y end

%%%%%%%%%%%%%%%%%%% Chapter - 7 %%%%%%%%%%%%%%%%%%%%%%

% 7.1
fun {Identity X} X end

% 7.5
fun {TrueMaker X} true end

% 7.7
{Browse 7#hot(true)}

% 7.9
{Browse 9#cold(10)}

% 7.10
{Browse 10#cold(5)}

% 7.11
fun {HotMaker X} hot end

% 7.20
fun {Help F}
   hot(
      {TrueMaker
         if {TrueMaker 5}
            then F
            else TrueMaker
         end})
end

% 7.47
fun {Ints N}
   link(N+1 Ints)
end

% 7.51
{Browse 51#{Ints 0}}

% 7.53
{Browse 53#{Ints 5}}

% 7.54
{Browse 54#{Ints 13}}

% 7.55
{Browse 55#{Ints 50005}}

% 7.58
fun {Skips N}
   link(N+2 Skips)
end

% 7.59
{Browse 59#{Skips 8}}

% 7.60
{Browse 60#{Skips 17}}

% 7.61
fun {DividesEvenly N C}
   {EqInt (N mod C) 0}
end
fun {IsMod5or7 N}
   if {DividesEvenly N 5}
      then true
      else {DividesEvenly N 7}
   end
end

% 7.62
fun {SomeInts N}
   if {IsMod5or7 N+1}
      then link(N+1 SomeInts)
      else {SomeInts N+1}
   end
end

% 7.63
{Browse 63#{SomeInts 1}#{SomeInts 17}#{SomeInts 116}}

% 7.66
{Browse 66#{Ints 0}}

% 7.67
{Browse 67#{Ints 1}}

% 7.68
{Browse 68#{Ints 2}}

% 7.71
{Browse 71#{SomeInts 0}}

% 7.72
{Browse 72#{SomeInts 5}}

% 7.76
fun {ChainItem N link(I F)}
   if {EqInt N 1}
      then I
      else {ChainItem N-1 {F I}}
   end
end

% 7.84
{Browse 84#{ChainItem 1 {SomeInts 0}}}
{Browse 84#{ChainItem 6 {SomeInts 0}}}
{Browse 84#{ChainItem 37 {SomeInts 0}}}

% 7.94
fun {IsPrime N}
   fun {HasNoDivisors N C}
      if C == 1
         then true
         else
            if {DividesEvenly N C}
               then false
               else {HasNoDivisors N C-1}
            end
      end
   end
in
   {HasNoDivisors N N-1}
end

% 7.90
{Browse 90#{IsPrime 3}}

% 7.91
{Browse 91#{IsPrime 81}}

% 7.96
fun {Primes N}
   if {IsPrime N+1}
      then link(N+1 Primes)
      else {Primes N+1}
   end
end

% 7.96
{Browse 96#{ChainItem 12 {Primes 1}}}

% 7.98
fun {Fibs N}
   fun {$ M}
      link(N+M {Fibs M})
   end
end

% 7.106
{Browse 106#link(0 {Fibs 1})}

% 7.109
fun {Fibs_1 M}
   link(1+M {Fibs M})
end

% 7.112
{Browse 112#{{Fibs 1} 1}}

% 7.114
{Browse 114#{Fibs_1 1}}

% 7.115
{Browse 115#{Fibs_1 2}}

% 7.116
fun {Fibs_2 M}
   link(2+M {Fibs M})
end

Chris Rathman / Chris.Rathman@tx.rr.com