Re: ADTs in Euphoria

new topic     » goto parent     » topic index » view thread      » older message » newer message

> From: S Ns

I think you can do what you're looking for fairly easily in Eu.

> I don't know if this is possible, but I'll just sketch
> it anyway as indication.  Look at a binary tree:
>
> The node is a 3-element sequence where element:
> 1. is the data (this could be a record - represented as a
>    sequence of course)
> 2. is the left child which is a node sequence like the
>    parent (recursive)
> 3. is the right child like 2.

So:

sequence tree
tree = { "root",
                { "node1", { "node11", {}, {}}, { "node12", {} {} }},
                { "node2", { "node21", {}, {}}, { "node22", {}, {}}}}


> I don't know if 2 and 3 are possible in this fashion.

Technically, the complexity of a sequence is only limited by available
memory.

> I don't think that this is the same as Jeff's
> mutlidimensional sequence.

Actually, it probably is.

> If this is possible in Eu then we have to implement some
> operations: e.g. assume our tree is tree1:
>
> our interface operations could be:
>
>  tree_new(tree1)
>  tree_add(tree1, some_data)
>  tree_find(tree1, some_data)
>  tree_copy(tree2, tree1)

For this I think we need to know a little more about the structure of the
data in the tree, and what exactly you want these functions to do.  But it
should be pretty simple once you know what you want to do.

Matt Lewis
http://www14.brinkster.com/matthewlewis

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu