Oz/Mozart    hoch http://www.mozart-oz.org
 
 


  Fakultät (1)   Michael Neumann
declare
Fact = proc {$ N Z}
          if N > 1 then Z = N * {Fact N-1}
          else Z = 1 end
       end

local Z in
   {Fact 6 Z} {Browse ['Fact(6) = ' Z]}
end
Berechnet die Fakultät. Ergibt 720.


  Fakultät (2)   Michael Neumann
declare
proc {Fact N Z}
   if N > 1 then Z = N * {Fact N-1}
   else Z = 1 end
end

local Z in
   {Fact 6 Z} {Browse ['Fact(6) = ' Z]}
end
Berechnet die Fakultät. Ergibt 720.


  Fakultät (3)   Michael Neumann
declare
proc {Fact N Z}
   case N
   of 0 then Z = 1
   [] X then Z = X * {Fact X-1}
   end
end

local
   Z
in
   {Fact 6 Z} {Browse ['Fact(6) = ' Z]}
end
Berechnet die Fakultät. Ergibt 720.


  Fakultät (4)   Michael Neumann
declare
fun {Fact N}
   case N
   of 0 then 1
   [] X then X * {Fact X-1}
   end
end

{Browse ['Fact(6) = ' {Fact 6}]}
Berechnet die Fakultät. Ergibt 720.


 Hello World   Michael Neumann
% Hello World!!!

{Show 'Hello World'}
Gibt "Hello World" auf dem Bildschirm aus.


 Hello World (2)   Michael Neumann
% Compile:
%   > ozc -x hw.oz
% Run:
%   > ./hw
functor
import
  Application
  System
define
  {System.printInfo "Hello World\n"}
  {Application.exit 0}
end
Gibt "Hello World" auf dem Bildschirm aus.


 Squares (1)   Michael Neumann
local ShowIt T in

   proc {ShowIt T}
      {Show T*T}
   end

   {For 1 10 1 ShowIt}
end
Gibt die Quadrate von 1 bis 10 aus.


 Squares (2)   Martin Henz
for I in 1..10 do {Show I*I} end
Gibt die Quadrate von 1 bis 10 aus.