I am trying to print a Fibonacci sequence in Oz using 2 approaches: a function and a procedure, using Emac as an editor. The procedure goes here:
declare fun {Fibo N} case N of 1 then 1 [] 2 then 1 [] M then {Fibo (M-1)} + {Fibo (M-2)} end end declare proc {Loop K} if K ==1 then {Browse K} else {Loop K-1} {Browse {Fibo K}} end end {Loop 10}
and function:
declare fun {Fibo N} case N of 1 then 1 [] 2 then 1 [] M then {Fibo (M-1)} + {Fibo (M-2)} end end declare fun {Loo L} if L ==1 then {Browse L} else {Loo L-1} {Browse {Fibo L}} end end {Loo 10}
The problem is the only "Loop" procedure. Result:
1 1 2 3 5 8 13 21 34 55
The "Loo" function does not and throws some hard-to-understand errors:
%********************** static analysis error ******************* %** %** illegal arity in application %** %** Arity found: 1 %** Expected: 2 %** Application (names): {Loo _} %** Application (values): {<P/2> _<optimized>} %** in file "Oz", line 13, column 6 %********************** static analysis error ******************* %** %** illegal arity in application %** %** Arity found: 1 %** Expected: 2 %** Application (names): {Loo _} %** Application (values): {<P/2> 10} %** in file "Oz", line 17, column 0 %** ------------------ rejected (2 errors)
I still donβt know why. In my opinion, function and procedure have a similar effect in OZ.
Silentbang
source share