[mercury-users] New to mercury: structure reuse and efficiency
Ralph Becket
rafe at cs.mu.OZ.AU
Thu Jul 1 11:08:27 AEST 2004
Gregory D. Weber, Wednesday, 30 June 2004:
> There's an implied question here which I don't think has been answered:
> how _does_ he do what he wants to do here, which, I believe, is to
> make sure that H does not equal T before making the recursive call?
>
> Isn't the solution to write -- ?
>
> member([H | T], X) :-
> (
> H = X ->
> true
> ;
> member(T, X)
> ).
>
> or, equivalently,
>
> member([H | T], X) :-
> (
> if H = X
> then true
> else member(T, X)
> ).
Yes, either of those will do the trick.
-- Ralph
--------------------------------------------------------------------------
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