[mercury-users] Why is
Peter Ross
pro at missioncriticalit.com
Mon Mar 5 07:03:18 AEDT 2012
On Mar 5, 2012 5:42 AM, "Jeff Thompson" <jeff at thefirst.org> wrote:
>
> Hello. I would like to check my understanding here. List member is
defined as:
>
> member(X, [X | _]).
> member(X, [_ | Xs]) :- member(X, Xs).
>
> It is counter-intuitive to me why mode member(in, in) is semidet. If you
call member(1, [1, 1]), why doesn't the code above match twice which would
make this mode nondet?
>
The in in mode doesn't bind any output variables, so it must either just
succeed or fail.
Declaratively it is irrelevant that it can succeed in two different ways.
The out in mode is nondet because it will bind output variables if it
succeeds.
Pete
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mercurylang.org/archives/users/attachments/20120305/f971cc7c/attachment.html>
More information about the users
mailing list