[mercury-users] higher order modes
Fergus Henderson
fjh at cs.mu.OZ.AU
Tue Sep 12 19:32:19 AEDT 2000
On 12-Sep-2000, Michael Day <mcda at students.cs.mu.oz.au> wrote:
>
> Incidentally, do true and fail exist in any real form anywhere?
Yes, the standard library module std_util defines procedures
`semidet_succeed' and `semidet_fail'.
> As I can't seem to return them in lambda expressions.
Syntactically, `true' and `fail' are builtin goals, not predicates,
so you can't use them directly in expressions as higher-order terms.
Thus `list__filter(true, L0, L)' won't do what you want.
You can however use them in lambda expressions,
e.g. `list__filter((pred is semidet :- true), L0, L)'.
Alternatively you can use semidet_succeed and semidet_fail,
e.g. `list__filter(semidet_succeed, L0, L)'.
If `true' and `fail' were treated as builtin predicates rather than
as goals, so that they could be used directly in expressions as
higher-order terms, that probably wouldn't help, since they wouldn't
have the right determinism. The determinism of `true' would be `det',
and the determinism of `fail' would be `failure', but no doubt the
higher-order procedure that you're trying to pass them to expects
something of determinism `semidet'.
--
Fergus Henderson <fjh at cs.mu.oz.au> | "I have always known that the pursuit
WWW: <http://www.cs.mu.oz.au/~fjh> | of excellence is a lethal habit"
PGP: finger fjh at 128.250.37.3 | -- the last words of T. S. Garp.
--------------------------------------------------------------------------
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