[mercury-users] (Newbie) translating this from Prolog?
Maurizio Colucci
seguso.forever at tin.it
Sun Mar 21 06:01:41 AEDT 2004
On Saturday 20 March 2004 19:09, Fergus Henderson wrote:
> Do the predicates in the list have side effects?
> If not, this can be translated as
>
> :- pred holds(list(pred)).
> :- mode holds(in(list_skel(pred is semidet))) is semidet.
>
> holds(List) :-
> all [M] (member(M, List) => call(M)).
>
> If they have side effects, but can't fail, then it could be translated to
>
> :- pred holds(list(pred(io__state, io__state), io__state,
> io__state). :- mode holds(in(list_skel(pred(di,uo) is det))) is det.
>
> holds([]) --> [].
> holds([M|Ms]) --> call(M), holds(Ms).
>
> If the predicates in the list have side effects but can fail,
> then you'd probably need to rewrite them so that they return a
> value of type bool or maybe(T) rather than failing.
Thank you, this code is very instructive. I am going to study it.
(PS: I couldn't find "all" in the reference manual, maybe it's my fault)
Mau
--------------------------------------------------------------------------
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