Created
March 16, 2012 15:02
-
-
Save jnunemaker/2050450 to your computer and use it in GitHub Desktop.
Two dimensional list prototype in Io
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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