From: rashworth Date: 2001-05-02T11:15:58+09:00 Subject: [ruby-talk:14529] Re: Large Matrix Thanks for your note. Dave also wrote and said: my_array = (1..50).map { (1..50.map { '+' } } my_array[2][2] = "a" puts my_array.collect {|row| row.join } This works fine. Thanks again. ERA ---------- Original Message ---------------------------------- From: Mark Slagell Reply-To: ruby-talk@ruby-lang.org Date: Tue, 1 May 2001 12:56:28 +0900 >rashworth spake: >> >> The map works fine, but I am not able to redefine >> map[2][2] = "a" ? and then print map > >Redefining an element should work. Are you giving a name to the matrix? >e.g., > > myMatrix = (1..50).map { (1..50).map { '+' } } > >Then myMatrix[2][2] = 'a' would redefine that element of the matrix. >See, umm, I think you don't want to be calling the matrix 'map'. You >could, but it sounds potentionally bad for your karma, confusing an >action (map) with the result of that action (the matrix it gives you). > >As for printing, I'm not sure what you have in mind. > > -- M > > >> ---------- Original Message ---------------------------------- >> From: Dave Thomas >> Reply-To: ruby-talk@ruby-lang.org >> Date: Tue, 1 May 2001 12:07:48 +0900 >> >> >"rashworth" writes: >> > >> >> What is the Ruby code to define a large matrix, 50 by 50 >> >> elements with each one equal to "+"? Thank you. ERA >> > >> > (1..50).map { (1..50).map { '+' } } >