POV-Ray : Newsgroups : povray.general : Flatten n-dimension array? : Re: Flatten n-dimension array? Server Time
29 Jul 2024 10:21:58 EDT (-0400)
  Re: Flatten n-dimension array?  
From: Warp
Date: 18 Oct 2011 10:22:31
Message: <4e9d8ba5@news.povray.org>
[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

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.