POV-Ray : Newsgroups : povray.newusers : Array coding problem : Re: Array coding problem Server Time29 Jan 2023 20:40:23 EST (-0500)
 Re: Array coding problem
 From: clipka Date: 20 Sep 2016 13:22:08 Message: <57e17040\$1@news.povray.org>
```
{
"@context": "https://schema.org",
"@type": "DiscussionForumPosting",
"@id": "#57e17040%241%40news.povray.org",
"dateCreated": "2016-09-20T17:22:08+00:00",
"datePublished": "2016-09-20T17:22:08+00:00",
"author": {
"@type": "Person",
"name": "clipka"
}
}
Am 20.09.2016 um 17:39 schrieb AQ:
> I want to fill a 6 by 3 array with either a 0 or a 1 chosen at random
> and then use these values in a colour map.  I thought it would be easy
> but the code below gives an error and I cannot see why.
>
> #declare Col = array[7][4]
> #for (j,0,6,1)
>   #for (k,1,3,1)
>     Col[j][k] = int(2*rand(R))

You'll want to use

#declare Col[j][k] = int(2*rand(R))

> colour_map {
>               [0.0/6  rgb < Col[0,1], Col[0,2], Col[0,3] >]
>               [1.0/6  rgb < Col[1,1], Col[1,2], Col[1,3] >]
>               [2.0/6  rgb < Col[2,1], Col[2,2], Col[2,3] >]
>               [3.0/6  rgb < Col[3,1], Col[3,2], Col[3,3] >]
>               [4.0/6  rgb < Col[1,1], Col[4,2], Col[4,3] >]
>               [5.0/6  rgb < Col[5,1], Col[5,2], Col[5,3] >]
>               [6.0/6  rgb < Col[6,1], Col[6,2], Col[6,3] >]
>             }

You'll also want to replace Col[x,y] with Col[x][y].
```