axiom-mail
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Axiom-mail] Programming with BTREEs.


From: Simon Blomberg
Subject: [Axiom-mail] Programming with BTREEs.
Date: Tue, 7 Apr 2009 11:55:00 +1000

Hi,

I sent a message asking for help a couple of weeks ago. Thanks to those who responded. I have a more concrete question:

I am trying to write a simple recursive function to build binary trees from a List object. My test tree is the following:

treeList := [e,[5,1],[[a,[1,1],b], [1,1], [c,[1,2],d]]]

Each nested level contains a list of three elements, which are to become the left branch, value, and right branch of the tree, respectively. For internal nodes, the value of the tree is a two-element list representing the left- and right branch lengths. The leaves of the tree are to be binary trees with a Symbol as the value (a to e) and empty left - and right branches. Here is my code:

buildTree(lst: List Any):BTREE(Any) == binaryTree(buildTree(lst.1), lst.2, buildTree(lst.3))
buildTree(val:Symbol):BTREE(Any)  == binaryTree(val)

However, calling buildTree(treeList) doesn't work. The second rule overwrites the first rule, even though the arguments are of different types. I'm still getting my head around how types are specified in Axiom, so any assistance would be greatly valued.

Thanks in advance,

Simon.

Simon Blomberg, BSc (Hons), PhD, MAppStat.
Lecturer and Consultant Statistician
School of Biological Sciences
The University of Queensland
St. Lucia Queensland 4072
Australia
T: +61 7 3365 2506
email: S.Blomberg1_at_uq.edu.au
http://www.uq.edu.au/~uqsblomb/

Policies:
1.  I will NOT analyse your data for you.
2.  Your deadline is your problem.

The combination of some data and an aching desire for
an answer does not ensure that a reasonable answer can
be extracted from a given body of data. - John Tukey.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]