Cabbage Logo
Back to Cabbage Site

Square brackets

I know it’s a trivial question now, but this syntax I found in some patches:
kArr2[kMaxIndx] = 0
What does it correspond to mathematically? What is the effect of the square brackets in this case?
Thanks for any answer!

Good question. These refer to the fact that kArr2 is a k-rate array. Meaning it holds a list of numbers. The paramrter passed within the square brackets indicates which number from the kArr2 list to access. It’s not that different from accessing a value from a function table. You can read more about arrays in Csound here.

Feel free to ask further questions if you have any. :slight_smile:

Thanks Rory,

I am also deepening the topic on the text by Lazzarini (and other authors) “Csound”.

Well, indeed this tool can become a valuable resource…

1 Like

I was also wondering how to represent this line of code with a flowchart:
kArr2[] init gitable

And also this other one:

kArr2[kMaxIndx] = 0

That’s a good question. I’m not really sure how best to show arrays in flowcharts. I guess there has to be some kind of general approach? But I’ve no idea. Maybe something like this?

Untitled Diagram.drawio

1 Like

Of course, it could be a way to graphically represent the array… :+1: