ozmozart

How to write a proper procedure in Oz?


I am very new to Oz, so sorry if this is somewhat basic. The following code, for calculating the area, diameter and circumference of a circle does not work. It throws an error saying "illegal arity in application". I have tried tweaking the code in many different ways, but often end up getting some kind of error.

Here is the code:

local
   Pi Area Diameter
   proc {Circle R}
      Pi = 355/113
      Area = R * R * Pi
      Diameter = R * 2.0
      {Browse Pi Area Diameter}
   end
in
   {Circle 2}
end

Does anyone know what might be wrong?

Thank you!


Solution

  • The problem comes from the fact that Browse expects only a single argument (it has "arity 1") and you're giving it 3 arguments.

    Try calling {Browse (Pi Area Diameter)} instead, to make the 3 different arguments into a single tuple. Another possibility is to call Browse 3 times instead.