From: John Nott Date: 2007-09-26T20:50:01+09:00 Subject: IntegreMatrix ------_=_NextPart_001_01C80033.3F27DEAE Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Hello All, I have put together some code (using a book as a guide!!) to create an in= teger matrix as follows: =20 class IntegerMatrix =20 =20def initialize(rows,cols) =20@rows, @cols =3D rows, cols =20@data =3D (0...rows).map{(0...cols).map{0}} end =20 =20attr_reader :rows, :cols =20 =20def dimensions =20[self.rows,self.cols] =20end =20 =20def get(rowidx, colidx) =20 @data[rowidx][colidx] =20end =20alias [] get =20 =20def put(rowidx,colidx,value) =20raise TypeError "non integer value in IntegerMatrix" unless =20 value.is_a? Integer =20 @data[rowidx][colidx]=3Dvalue =20 end =20 alias []=3D put =20 end =20=20 def to_s =20(0...self.rows).map{|r| =20(0...self.cols).map{|c| "%5d"%self[r,c]}.join(" ") =20}.join("\n") end =20 testm =3D IntegerMatrix.new(2,3) testm[0,0]=3D68; testm[0,1]=3D94; testm[0,2]=3D-2 testm[1,0]=3D11; testm[1,1]=3D7; testm[1,2]=3D50 =20 puts testm =20 and produces my test matrix as follows: =20 68 94 -2 11 7 50 =20 my problem is how do i take it to the next level so that it will read a .= csz file and populate the matrix with its contents?.. is there a straight= =20forward way to do this?.. or does anyone know any good websites/resour= ces that can help with this. =20 Cheers! =20 - John =20 #########################################################################= ############ This e-mail message has been scanned for Viruses and Content and cleared = by MailMarshal #########################################################################= ############ ------_=_NextPart_001_01C80033.3F27DEAE--