[mercury-users] bintree_set iterators? read_term to type conversions?

doug.auclair at logicaltypes.com doug.auclair at logicaltypes.com
Wed Feb 15 12:54:48 AEDT 2006


Dear all,

Hi!  It appears that bintree_set has only one form of iteration (using member/2 and delete/3): left-to-right traversal.  Unfortunately for me, my application requires top-to-bottom traversal.  Is there a way to achieve this? 

When I tried to create an iterator on the type (which appears to devolve to the functors tree/4 and empty/0), the compiler rejected my program -- these type discriminators are not accessable, it appears.  So next I wrote the representation out and then piped it into a program that read_term/3 off of stdin.  BUT, when I called try_term_to_type/2, that predicate resulted in an error(type_error/1).  So, then I declared a type:

:- type binary_tree ---> tree(string, unit, binary_tree, binary_tree); empty.

Still the same error/1 from the try_term_to_type/2 predicate, but I know the type is okay, because I can write/1 out a hardcoded instance:

write(tree("ar", unit, tree("ak", unit, empty, tree("al", unit, empty, empty)), tree("au", unit, empty, tree("az", unit, empty, empty)))).

Neither the term coming from stdin nor the example term above have any variables: both are entirely ground.

So: user controlled iteration over binary trees? Converting terms to declared types?  How can I do these things?

Sincerely,
Doug Auclair

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