Arc Forumnew | comments | leaders | submitlogin
2 points by fallintothis 5396 days ago | link | parent

Arc doesn't really have arrays, so it doesn't have 2-dimensional arrays. One approach is to use a list of lists.

  arc> (= plane '((a b c) (d e f) (g h i)))
  ((a b c) (d e f) (g h i))
  arc> ((plane 0) 0)
  a
  arc> ((plane 0) 1)
  b
  arc> ((plane 0) 2)
  c
  arc> ((plane 1) 2)
  f
But indexing linked lists is inefficient, so you could similarly nest hash tables.

Granted, neither solution is pretty. I suspect they aren't there because (as with many things) pg hasn't needed them yet himself.



1 point by akkartik 5396 days ago | link

Prettier syntax: arr.i.j

-----

2 points by fallintothis 5396 days ago | link

D'oh. My fingers were in pre-Arc3 mode, where that would've expanded into

  (arr i j)
But yeah, good point, that works now: http://arclanguage.org/item?id=9163. Thanks for spotting it.

-----