So since SPAD does not support the OO approach to this, how about
going to the opposite extreme and thinking how it would be done in a
purely functional language like Haskell. I haven't got very far with
learning Haskell yet but my guess would be that we would need to use
an 'algebraic data type' like this:
data SceneNode = rootNode [SceneNode]
| groupNode [SceneNode]
| lineNode [SceneNode]
| materialNode [SceneNode]
Could this be recursed over using Haskell methods? is there some way
that SPAD could use algebraic data type approach?
I haven't done this in SPAD, but it is basically, what is contained in
AldorCombinat.
http://www.risc.jku.at/people/hemmecke/AldorCombinat/
Look for example at
http://www.risc.jku.at/people/hemmecke/AldorCombinat/combinatsu69.html#x103-15000024.11
The simple line...
A(L: LabelType): CombinatorialSpecies L == (E + X*A*A)(L) add;
defines a tree A. But not a tree with an arbitrary number of branches,
but with exactly 2 at each node.
If you further down, you find
A(L: LabelType): CombinatorialSpecies L == (E + X*B*B*B)(L) add;
B(L: LabelType): CombinatorialSpecies L == (E + X*A*A)(L) add;
where A stands for a tree with three branches on each odd level node,
but two branches on each even level node.
I'm not yet completely sure whether this kind of structure would help
you, but I somehow have this in mind.
Can you perhaps write down a proper algebraic datatype for your scene
nodes. And please do it correctly, what you have given above is wrong,
since it would allow for a scene like
rootNode(rootNode(lineNode(),rootNode()), rootNode())
But if I understood you correctly, rootNode should only appear on the
top-level.
Actually, if you have such a proper description of your algebraic
datatype, it should be more or less straightforward to translate that
into SPAD.
But I have to give a warning, I'm not completely sure whether
1) this whole business of recursive structures can properly be handled
by SPAD, and
2) that kind of describing the nodes is really matching your use case.
Anyway, I think it's worth a try. We (yes also me) can only learn from
such an experiment.
Ralf
--
You received this message because you are subscribed to the Google Groups "FriCAS -
computer algebra system" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/fricas-devel?hl=en.