Illegal arity in application error

Peter Van Roy pvr at info.ucl.ac.be
Thu Feb 8 08:12:15 CET 2007


Craig Ugoretz wrote:
> Hello,
>  
>      I am trying to work assignment one, "train shunting" from CS2104 
> course notes presented on the supplements website for the Van Roy and 
> Haridi book to help me learn the Oz language.  I don't understand why 
> I get a compile error for my code (a simplification of the assignment 
> one problem) since the function ApplyMoves clearly has just two 
> arguments.  The error, of course, says that it takes three?  When I 
> compile just the function, not the call to the function, I don't get 
> an error.
>  
>                                                                                      
> Craig
>  
> declare
> fun {ApplyMoves S Ms}
> %% S is the state, Ms the list of moves to be applied
> %% Returns list of resulting states
> case Ms
> of nil then S
> [] M|Mr then
> %% Compute S1 as new state
> S1 = case M
> of one(N) then
> if N>0 then 1 else 2 end
> [] two(N) then
> if N>0 then 3 else 4 end
>      end
> in
> S#{ApplyMoves S1 Mr}
> end
> end
> {ApplyMoves 0 [one(1) two(~1)]}
ApplyMoves is a function and you are calling it as a procedure.
You can replace the call by something like this:

{Browse {ApplyMoves 0 [one(1) two(~1)]}}

In the error message, 'Arity found: 2' means that you are calling
a procedure with 2 arguments.  'Expected: 3' means that the
definition of ApplyMoves has arity 3 (in the kernel language
there are only procedures and a function of 2 arguments is a
procedure of 3 arguments).

Peter




More information about the mozart-users mailing list