[mercury-users] Mercury applications, AI, backtracking
Fergus Henderson
fjh at cs.mu.OZ.AU
Mon Sep 14 16:32:36 AEST 1998
On 14-Sep-1998, Thomas Charles CONWAY <conway at cs.mu.OZ.AU> wrote:
> Here's a few thoughts:
...
> One place where backtracking is very useful is in checks - here the
> nondeterminism is usually within a very small scope:
> (
> all [V] (
> member(V, List) => some_property(V, ...)
> )
> ->
> do something
> ;
> else keep going ...
> ).
>
> In this kind of situation the use of local nondeterminism allows for a
> nice declarative notation for the invariant.
I don't think this is a strong argument, since as Don Smith noted,
you can use lists (or sets) to simulate nondeterminism in Haskell.
The above example can be written in Haskell as something like this:
if
all ( \ v -> some_property v ... ) list
then
do something
else
keep going ...
Now this is perhaps not quite as natural as the Mercury style,
but it's just an idiom, and once you know the idiom it becomes
pretty natural after a while.
--
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.
More information about the users
mailing list