Oz/Mozart
![]() |
http://www.mozart-oz.org |
Factorial (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 |
Calculates the factorial. Results
720 . |
Factorial (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 |
Calculates the factorial. Results
720 . |
Factorial (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 |
Calculates the factorial. Results
720 . |
Factorial (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}]} |
Calculates the factorial. Results
720 . |
Hello World | Michael Neumann |
% Hello World!!! {Show 'Hello World'} |
Prints "Hello World" onto the
screen. |
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 |
Prints "Hello World" onto the
screen. |
Squares (1) | Michael Neumann |
local ShowIt T in proc {ShowIt T} {Show T*T} end {For 1 10 1 ShowIt} end |
Outputs the squares from 1 to
10. |
Squares (2) | Martin Henz |
for I in 1..10 do {Show I*I} end |
Outputs the squares from 1 to
10. |