|
![](/i/fill.gif) |
Warp <war### [at] tag povray org> wrote:
> I'm too lazy to check now, but wouldn't dimension_size() return 0 for
> dimensions higher than what the array is?
The way I currently handle this is by using dimensions() to set the counter in a
for loop, which then measures each dimension individually [I assume oddly shaped
arrays] and utilizes this to produce a count of indices required in the 1D
array. This works based on my testing so far [not extensive].
> A recursive macro can be created to do what you want (once you know the
> dimensions of the array). It's not completely trivial to write, but shouldn't
> be too difficult either.
That seems to be the generic solution I've seen implemented in languages similar
to SDL. I wanted something cleaner, but that may not be an option.
If the urge strikes you, feel free to take a stab at it along with me. :p
I'll put some more effort into this, but since it isn't really for anything I'm
doing specifically, other than making a .mcr file of array utilities typically
found in many C based languages, I may abandon it for things more interesting
and less time consuming. time == money ;)
I need to make some more context-selected pseudo overloads for higher
dimensions/etc.., but so far I have:
IndexOf() [Vector, non-vector]
Contains() [Vector, non-vector]
Shuffle() [Fisher-Yates, Bruteforce]
Resize()
CountDefined()
Just those few have made a *lot* of things I usually do much less tedious.
Ian
Post a reply to this message
|
![](/i/fill.gif) |