Re: Non-deterministic operation

From: Wolfgang Lux <wlux_at_uni-muenster.de>
Date: Wed, 18 Aug 2004 20:00:12 +0200

Michael Hanus wrote:

> [...] Thus, we propose
> the name (?) instead, i.e., we like to add the following definitions
> to the standard prelude:
>
> infixl 0 ?
>
> (?) :: a -> a -> a
> x ? _ = x
> _ ? y = y
>
>
> Thus, the expression "1 ? 2 ? 3" non-deterministically evaluates
> to 1, 2, or 3. Nevertheless, we are open for other suggestions.

Just a minor nitpicking. It would be better to have infixr 0 ? instead
of infixl 0 ?, since this causes less non-deterministic splitting for
1 ? 2 ? 3 when computing only the first solution with a search strategy.
It is also operationally better behaved in a backtracking implementation
like PACKS (and the interactive top-level of MCC for that matter). And,
finally, this is also a useful hint to the users that she should prefer
using foldr1 (?) l instead of foldl1 (?) l in order to pick one element
non-deterministically from the list l.

Regards
Wolfgang


_______________________________________________
curry mailing list
curry_at_lists.RWTH-Aachen.DE
http://MailMan.RWTH-Aachen.DE/mailman/listinfo/curry
Received on Do Aug 19 2004 - 09:32:30 CEST

This archive was generated by hypermail 2.3.0 : Do Jun 20 2024 - 07:15:06 CEST