Skip to content

Instantly share code, notes, and snippets.

@alexlenail
Created November 5, 2018 22:13
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 alexlenail/8ccabf438444454fde347746c8941f74 to your computer and use it in GitHub Desktop.
Save alexlenail/8ccabf438444454fde347746c8941f74 to your computer and use it in GitHub Desktop.
matrix = {
values: [[1, 2], [3, 4]], // sorted row-wise by default
rows_iter: function () { return this.values },
columns_iter: function () { return iterator_over_the_transpose_of(this.values) },
flat_rows_iter: function () { return iterator_over_flattened(this.values) },
flat_columns_iter: function () { return iterator_over_the_flattened_transpose_of(this.values) },
rows: function () { return copy(this.values) },
columns: function () { return copy(transpose(this.values)) },
flat_rows: function () { return copy(flattened(this.values)) },
flat_columns: function () { return copy(flattened(transpose(this.values))) },
transpose: function() {
return {
values: transpose(this.values),
rows_iter: function () { return this.values },
columns_iter: function () { return iterator_over_the_transpose_of(this.values) },
flat_rows_iter: function () { return iterator_over_flattened(this.values) },
flat_columns_iter: function () { return iterator_over_the_flattened_transpose_of(this.values) },
rows: function () { return copy(this.values) },
columns: function () { return copy(transpose(this.values)) },
flat_rows: function () { return copy(flattened(this.values)) },
flat_columns: function () { return copy(flattened(transpose(this.values))) },
}
},
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment