|
![](/i/fill.gif) |
In article <3c9ef692@news.povray.org> , "Thorsten Froehlich" <tho### [at] trf de>
wrote:
> Actually, the following at least seems to work. Of course, I have not checked
> if it doesn't corrupt any internal data:
>
> #declare foo = array[40];
>
> #declare foo[1] = array[10];
> #declare foo[2] = array[5];
>
> #declare foo[1][5] = 5.0;
>
> As far as I can tell this is, together with the ability to undef arrays
> sufficient to build linked structures...
For example:
#declare treeroot = array[3];
#declare rd = seed(1);
#macro randfilltree(node, i)
#declare node[2] = array[1];
#declare node[2][0] = rand(rd) * 1000 + 10;
#if(i > 0)
#if(rand(rd) > 0.1)
#declare node[0] = array[3];
randfilltree(node[0], i - 1)
#end
#if(rand(rd) > 0.1)
#declare node[1] = array[3];
randfilltree(node[1], i - 1)
#end
#end
#end
#macro dumptree(node)
#debug " ("
#debug str(node[2][0], 0, 0)
#if(defined(node[0]))
dumptree(node[0])
#end
#if(defined(node[1]))
dumptree(node[1])
#end
#debug ")"
#end
#macro findmaxtree(node)
#if(defined(node[0]) & defined(node[1]))
max(node[2][0], findmaxtree(node[0]), findmaxtree(node[1]))
#else
#if(defined(node[0]))
max(node[2][0], findmaxtree(node[0]))
#else
#if(defined(node[1]))
max(node[2][0], findmaxtree(node[1]))
#else
0
#end
#end
#end
#end
randfilltree(treeroot, 6)
#debug str(findmaxtree(treeroot), 0, 0)
dumptree(treeroot)
____________________________________________________
Thorsten Froehlich, Duisburg, Germany
e-mail: tho### [at] trf de
Visit POV-Ray on the web: http://mac.povray.org
Post a reply to this message
|
![](/i/fill.gif) |