For the weekend, please enjoy these add-ons to the Matrix class. Now, I'm off to hack together a fix for Matrix#coerce.
require 'matrix' class Matrix def []=(row,col,value) @rows[row][col] = value end def include?(search_term) @rows.each do |row| return true if row.include?(search_term) end false end def to_float @rows.each do |row| row.each_index do |index| value = row.at(index) row[index] = value.to_f if value.kind_of? Fixnum end end end def to_int @rows.each do |row| row.each_index do |index| value = row.at(index) row[index] = value.to_i if value.kind_of? Float end end end end
Argh, you got me.
For at least a second or two, I was trying to figure out why this was a joke related to the Matrix movie.