[mercury-users] boolean expressions from semidet predicates
Mark Brown
mark at cs.mu.OZ.AU
Sun Apr 23 03:52:37 AEST 2006
On 21-Apr-2006, Nicholas Nethercote <njn at csse.unimelb.edu.au> wrote:
> Hi,
>
> I want to write something like this:
>
> require((0 < X) and (X < 10))
>
> But I can't work out if it's possible to combine semidet operations in this
> way. 'and' doesn't work, '/\' doesn't work (I'm not even sure what 'and'
> and '/\' are, since the reference manual seems to only list the operators
> without explaining what they do),
It's only concrete syntax. `X and Y' means the same thing as `and(X, Y)'.
As for what they "are": `/\' is ISO-Prolog and `and' is an NU-Prolog
extension.
> and ',' doesn't work because you can't
> have a goal inside require/1.
The argument to require/1 is a closure. You can use an explicit lambda
expression or use the `Term(Args)' shorthand (of which `0 < X' is an
example).
>
> Is this possible,
You can always define `and/2' and `or/2' to mean conjunction and
disjunction. Or think of a meaningful name for your condition and
define a predicate that does what you want.
Cheers,
Mark.
--------------------------------------------------------------------------
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