-
-
Save abo-elleef/c3c13784da78462acf68580374e9f680 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
class Matrix | |
def &(matrix) | |
Matrix.Raise ErrDimensionMismatch, "Matrix dimension mismatch" unless (row_count == matrix.row_count && column_count == matrix.column_count) | |
rows = Array.new(row_count) {|i| | |
Array.new(column_count) {|j| | |
self[i, j] & matrix[i, j] | |
} | |
} | |
new_matrix rows, matrix.column_count | |
end | |
end | |
a = Matrix.rows [[true, false], [true, true], [false, false], [false, true]] | |
b = Matrix.rows [[false, true], [false, true], [true, false], [true, true]] | |
a & b |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment