[mercury-users] Handy Programming tool for Mercury.

Thomas Conway conway at cs.mu.OZ.AU
Thu May 13 08:58:15 AEST 1999


On Wed, May 12, 1999 at 09:22:42AM EST, Richard A. O'Keefe wrote:
> The other comment is that I would have thought that
> 	set_a(New_A_Value, Old_Foo, New_Foo)
> would have fitted into DCG notation rather better, so that
> one could do
> 	change_all(X) -->
> 	    set_a(1),
> 	    set_b('c'),
> 	    set_c("dee"),
> 	    set_d(X).

FWIW, since one ends up wanting a mini-dcg inside another predicate,
here is a programming trick I use:

	... some non-dcg code ...
	call((pred(in, out) is det -->
		set_a(1),
		set_b('c'),
		set_c("dee"),
		set_d(X)
	), OldState, NewState),
	...

Note that because you can't curry outputs, the higher order expression
can only take inputs. If you want outputs you need to curry them
explicitly:

	call((pred(Res0::out, in, out) is det -->
		set_a(1),
		set_b('c'),
		set_c("dee"),
		set_d(X),
		get_e(Res0)
	), Res, OldState, NewState),

Thomas
ps I know the syntax isn;t as elegant as haskell, but its a good deal
better than nothing.
-- 
 Thomas Conway  )O+  |  Team Register has a Pentium III. Its serial number is
     Mercurian       |  00000672000226FA025D71BF. We are not afraid.
<conway at cs.mu.oz.au> |    -- from http://www.theregister.co.uk
--------------------------------------------------------------------------
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