[GDS|Entropy] <nomail@nomail> wrote:
> Is there a way in SDL to flatten an n-dimensional array?
> Everything I've tried so far seems to require knowing the array size in advance
> and accessing specifically: flat[foo] = array[x][y]
> It looks like the only way to make a method which can take an array as input and
> flatten it will need to have a switch statement in it to fork to appropriately
> deep loops. I don't like that though.
> Any other options?
I'm too lazy to check now, but wouldn't dimension_size() return 0 for
dimensions higher than what the array is? (It could also cause an error,
in which case this couldn't be used.)
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.
--
- Warp
Post a reply to this message
|