[mercury-users] mixing function rules and predicate rules

Mike Burrell public+lceliw at wizardlike.ca
Fri Oct 1 01:06:24 AEST 2010


This might be a silly question, but is there a way to use predicates
within a function or vice versa? E.g., let's say p1 and p2 are
predicates and f is a function. I'd like to do something like:

f(X) = A ++ B where p1(X, Z, A), p2(Z, B).

obviously this doesn't work, but I don't know if there's syntax to
accomplish what I'm trying to do. The only way I've found so far is to
just change f into a predicate and make it something like:

f(X, R) :- p1(X, Z, A), p2(Z, B), R = A ++ B.

Is there a better way to do this? I'm not experienced enough to be
totally comfortable in logic programming still and I'm still not
understanding how functional and logic programming meet together.

Thanks,
Mike
--------------------------------------------------------------------------
mercury-users mailing list
Post messages to:       mercury-users at csse.unimelb.edu.au
Administrative Queries: owner-mercury-users at csse.unimelb.edu.au
Subscriptions:          mercury-users-request at csse.unimelb.edu.au
--------------------------------------------------------------------------



More information about the users mailing list