Skip to content

Instantly share code, notes, and snippets.

@pietro909
Last active May 18, 2016 09:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pietro909/39ddf106c0a96cfa27b829a22e9e05d7 to your computer and use it in GitHub Desktop.
Save pietro909/39ddf106c0a96cfa27b829a22e9e05d7 to your computer and use it in GitHub Desktop.
SLISW - IO - 2.5
Matrix := Object clone
Matrix dim := method(x, y,
self matrix := list();
for(1, 0, x - 1, 1,
row := list();
for(1, 0, y - 1, row push(0));
matrix push(row)
)
)
Matrix set := method(x, y, value,
self matrix at(x) atPut(y, value)
)
Matrix get := method(x, y,
self matrix at(x) at(y)
)
Matrix transpose := method(
transposed := Matrix clone;
transposed dim(self matrix at(0) size, self matrix size)
for(r, 0, self matrix size - 1, 1,
for(c, 0, self matrix at(r) size - 1, 1,
transposed set(c, r, self matrix at(r) at(c))
)
)
return transposed;
)
Matrix show := method(
self matrix map(row, row println)
)
Matrix showThis := method(matrix,
matrix map(row, row println)
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment