POV-Ray : Newsgroups : povray.advanced-users : Directly accessing array value in array of arrays Server Time
22 Dec 2024 04:38:14 EST (-0500)
  Directly accessing array value in array of arrays (Message 1 to 2 of 2)  
From: Bald Eagle
Subject: Directly accessing array value in array of arrays
Date: 6 Apr 2017 16:55:00
Message: <web.58e6aa331b66056880403a200@news.povray.org>
Let's suppose I have:



#version 3.7;
global_settings {assumed_gamma 1.0}


#declare Scalar = array [5] {0, 1, 2, 3, 4}
#declare Vector = array [5] {<0, 0, 0>, <1, 1, 1>, <2, 2, 2>, <3, 3, 3>, <4, 4,
4>}
#declare String = array [5] {"A", "B", "C", "D", "E"}

#declare BigArray = array [3] {Scalar, Vector, String}



How do I access one of the values in the sub-arrays through BigArray / in a
single step ?
It doesn't appear that there's a sensible syntax for that.

#declare Var1 = BigArray[0];
would only make Var1 the whole scalar array, and it's only a 1-dimensional array
of 3 other arrays, so I can't use two bracketed values...


Post a reply to this message

From: clipka
Subject: Re: Directly accessing array value in array of arrays
Date: 8 Apr 2017 05:10:01
Message: <web.58e8a89f6396be9db76e39c80@news.povray.org>
"Bald Eagle" <cre### [at] netscapenet> wrote:
> Let's suppose I have:
>
>
>
> #version 3.7;
> global_settings {assumed_gamma 1.0}
>
>
> #declare Scalar = array [5] {0, 1, 2, 3, 4}
> #declare Vector = array [5] {<0, 0, 0>, <1, 1, 1>, <2, 2, 2>, <3, 3, 3>, <4, 4,
> 4>}
> #declare String = array [5] {"A", "B", "C", "D", "E"}
>
> #declare BigArray = array [3] {Scalar, Vector, String}
>
>
>
> How do I access one of the values in the sub-arrays through BigArray / in a
> single step ?
> It doesn't appear that there's a sensible syntax for that.
>
> #declare Var1 = BigArray[0];
> would only make Var1 the whole scalar array, and it's only a 1-dimensional array
> of 3 other arrays, so I can't use two bracketed values...

ARRAY_IDENTIFIER[N] returns an element of an array, but it also qualifies as an
identifier itself; so if that element happens to be an array as well, it also
qualifies as an array identifier. So to access an element of /that/, you can
simply prepend another set of brackets.

For instance, `BigArray[2][3]` should work fine, returning "D".


Post a reply to this message

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