Illegal arity in application error
Filip Konvička
filip.konvicka at logis.cz
Thu Feb 8 08:37:07 CET 2007
Oh, sorry, Craig and all, I did not pay attention to your code, so sorry
for the bad advice....Juergen is of course right; I thought that
ApplyMoves is a procedure rather than a function.... so please ignore my
previous post.
F.
> Hi Craig,
>
> purely from syntax point of view, the line
>
> S#{ApplyMoves S1 Mr}
>
> is an expression, but it is the last "statement" of your procedure.
> There are in fact two problems here - you try to return a value from
> ApplyMoves, and you are using {ApplyMoves ...} at expression position.
>
> More specifically, the above line has the form A#B (i.e. a tuple with
> values A, B at the features 1 and 2, respectively), where A=S and
> B={ApplyMoves S1 Mr}, so the compiler thinks that ApplyMoves is a
> function with 2 input argument, i.e. a procedure with 2 input
> arguments and 1 output argument, ergo 3 arguments total - which is
> exactly what it tells you.
>
> Hope this helps (ask more if you need more help)
> Filip
>> 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 th e function, I don't get
>> an error.
>>
>>
>> C raig
>>
>> 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)]}
>>
>>
>> %********************** static analysis error *******************
>> %**
>> %** illegal arity in application
>> %**
>> %** Arity found: 2
>> %** Expected: 3
>> %** Application (names): {ApplyMoves _ _}
>> %** Application (values): {<P/3> 0 nil}
>> %** in file "c:/Documents and
>> Settings/Compaq_Owner/Desktop/ApplyMoves2.oz", line 20, column 0
>> %** ------------------ rejected (1 error)
>> ------------------------------------------------------------------------
>>
>> _________________________________________________________________________________
>>
>> mozart-users mailing list
>> mozart-users at mozart-oz.org
>> http://www.mozart-oz.org/mailman/listinfo/mozart-users
>
>
--
Filip Konvička
LOGIS, s.r.o.
tel. +420 556 841 100
mob. +420 736 758 714
More information about the mozart-users
mailing list