[mercury-users] Beginner question about pairs
Dave Slutzkin
dave_slutzkin at yahoo.com
Sun Jun 17 22:43:30 AEST 2001
--- Dave Slutzkin <dave_slutzkin at yahoo.com> wrote:
I apologise for the waste of space... As always, it
takes fifteen minutes after you post for the solution
to hit you. My mistake was assuming that a compiler
error message is actually useful :-). It actually
applied to a different line. (But it seems that a
clause is parsed without any whitespace.)
> :- pred
> check_place(pair(int,int),list(pair(int,int))).
> :- mode check_place(in,in) is det.
> check_place(_,[]).
> % line 69 follows...
> check_place(X-Y,[(OldX-OldY)|Rest]) :-
> cptemp(X,Y,OldX,OldY) ,
> (if (Y=OldY) then fail else true) ,
> (if abs(minus(OldX,X))=abs(minus(OldY,Y)) then fail
> else true) ,
> check_place(X-Y,Rest).
The error:
> n_queens.m:069: In clause for predicate
> `n_queens:check_place/2':
> n_queens.m:069: error: ambiguous overloading
> causes
> type ambiguity.
> n_queens.m:069: Possible type assignments include:
> n_queens.m:069: V_10 :: int or (pred int)
This was because the compiler wasn't sure whether the
two expressions containing 'abs' referred to the func
(with type = int) or the pred (with type pred int)
abs. To resolve it, I changed to the predicate
version of abs.
Sorry for posting all this, but it could be helpful to
someone out there.
Was there another way to do this? Am I correct in my
diagnosis?
Thanks, Dave.
Benjamin St, Parkville, Melbourne, Australia.
_____________________________________________________________________________
http://messenger.yahoo.com.au - Yahoo! Messenger
- Voice chat, mail alerts, stock quotes and favourite news and lots more!
--------------------------------------------------------------------------
mercury-users mailing list
post: mercury-users at cs.mu.oz.au
administrative address: owner-mercury-users at cs.mu.oz.au
unsubscribe: Address: mercury-users-request at cs.mu.oz.au Message: unsubscribe
subscribe: Address: mercury-users-request at cs.mu.oz.au Message: subscribe
--------------------------------------------------------------------------
More information about the users
mailing list