Skip to content

Instantly share code, notes, and snippets.

@jnunemaker
Created March 16, 2012 15:02
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jnunemaker/2050450 to your computer and use it in GitHub Desktop.
Save jnunemaker/2050450 to your computer and use it in GitHub Desktop.
Two dimensional list prototype in Io
TwoDimensionalList := Object clone
TwoDimensionalList list := List clone
TwoDimensionalList dim := method(x, y,
for(i, 1, y,
self list push(List clone setSize(x))
self
)
)
TwoDimensionalList set := method(x, y, value,
self list at(y) atPut(x, value)
value
)
TwoDimensionalList get := method(x, y,
self list at(y) at(x)
)
twoDim := TwoDimensionalList clone dim(2, 4)
twoDim set(0, 0, "foo")
twoDim set(1, 0, "bar")
twoDim set(0, 1, "baz")
twoDim set(1, 1, "wic")
twoDim get(0, 0) println
twoDim get(1, 0) println
twoDim get(0, 1) println
twoDim get(1, 1) println
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment