[mercury-users] Binding variables in an if then else?
Fergus Henderson
fjh at cs.mu.OZ.AU
Fri Aug 27 12:49:27 AEST 2004
On 09-Aug-2004, Peter Schachte <schachte at cs.mu.OZ.AU> wrote:
> > Suppose we have a variable that we want to decompose or unify, say
> > AList = [1,2,3]
> >
> > I want to assign the values in AList to V1, V2, and V3, respectively.
> >
> > ( AList = [A1, A2, A3] ->
> > V1 = A1,
> > V2 = A2,
> > V3 = A3
> > ;
> > throw("Something is wrong")
> > )
> >
> > Is it possible to write this more compactly?
( AList = [_, _, _] ->
Alist = [V1, V2, V3]
;
throw("Something is wrong")
)
> I think the nicest thing for cases like this would be to write
> something like:
>
> expect(Alist = [A1, A2, A3])
>
> (maybe even make expect a prefix operator.)
>
> The semantics of expect(X) would be the same as that of X, except that
> failure of X would be transformed into an exception much like your
> example above, so if the determinism of X were semidet, expect would
> be det, and similarly for nondet => multi.
The reason that I did not want something along those lines is that
the semantics becomes mode-dependent.
--
Fergus Henderson | "I have always known that the pursuit
| of excellence is a lethal habit"
WWW: <http://www.cs.mu.oz.au/~fjh> | -- 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