I found info about a module in Oz that contains procedures operating on lists here: https://mozart.github.io/mozart-v1/doc-1.4.0/base/list.html
But I have been trying different procedures in different ways, for example:
declare
proc {Length L}
I
in
{List.length +L ?I}
{Browse I}
end
declare
L=[1 2 3 4]
in
{Length L}
And what I get is a type error, I hope you can help me to know why, I'm very new using OZ
The problem is in the arguments you pass to List.length
. You should not use the '+' symbol. It is the operator for the addition. Simply call
{List.length L ?I}
The '+' symbol is used in the documentation to show what is the purpose of the arguments. The '+' symbol denotes an input argument while '?' denotes an output argument.
Besides, you can use '?' in your code for clarity, it is supported by Oz.
Also, the List
module should be imported by default. So you do not have to define a function Length
that uses List.length
, you can simply use
{Browse {Length [1 2 3 4 5]}}
to browse the length of the list given as argument.