[mercury-users] Help: generic tree predicates; modules

Bob McKay bob_mckay at mac.com
Thu May 9 23:44:31 AEST 2002


Firstly, Ralph, Simon, Richard, thanks to all three of you for your
very quick and helpful responses. On the modules, it looks like I'll
have to stick to libraries for the moment; the OSX installation was
slow and painful enough to not want to upgrade too often, so I'll
wait until the directory mapping is in a major release.

I ended up going with Richard's tmap function, partly because I'm
going to be doing other tree manipulation processes and it seemed
like a nicely general way of doing things (but I should have known,
Richard, that what you call 'simpler' is probably going to be a few
hours of hard thinking...) Anyway, I've finally got the Mercury
type system to accept the code and it's working nicely (the problem
is my understanding of the type system, not the system itself, I
hasten to add).

So on to the next challenge, which is to plug a newly generated
subtree in a specific (randomly generated) position (the numeric
position in an infix traversal) in an existing tree (I'm being
careless with my phrasing, but you know what I mean):

insert:: Exp,int,Exp -> Exp

I think this could be done in two stages with tmap, first producing
a numbered tree, then generating the new tree. But that seems likely
to be fairly inefficient in both space and time. Of course, I can
just do the traverse-and-plug algorithm, but that now seems somewhat
inelegant after the four-line tmap solution. Is there some magic I'm
missing here?

	Best Wishes
	Bob McKay

--------------------------------------------------------------------------
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