Manually populating arrays?

Hey John,

[Edit: as of Oct '21’s firmware v3.2 and 2.28, array literals are now supported!]

Array literals aren’t yet supported. Wizard (Ben) said it makes memory management harder and would require implementing a garbage collector.

So, to populate a 3x3, I would do this:

themes = array(3)
for (i = 0; i < 3; i++) themes[i] = array(3)
themes[0][0] = a
themes[0][1] = b
// etc

Sometimes I write a helper to let me to set a row compactly with arguments separated by commas.

assignRow3Col = (arr, r, c0, c1, c2) => { arr[r][0] = c0; arr[r][1] = c1; arr[r][2] = c2 }
assignRow3Col(themes, 0, a, b, c)

Or

assign3 = (c0, c1, c2) => { 
  arr = array(3)
  arr[0] = c0; arr[1] = c1; arr[2] = c2
  return arr 
}
themes[0] = assign3(a, b, c)