On Fri, Feb 15, 2013 at 3:55 PM, Joel Pearson <[email protected]> wrote:
> Hah, I wrote that head exploding comment first and then managed to work
> out what it did afterwards. Still took a few minutes of smashing my head
> into the desk to make room for the new thought though ;¬)
LOL
> Using a Hash sounds like a good idea. I already tried rewriting the
> selector into something a bit more excel-like (although I won't bore you
> with all the little changes):
Good!
> def []( addr )
> col, row = addr.upcase.scan( /([A-Z]+)(\d+)/ ).flatten
> data[ index( row, col ) ]
> end
>
> def []=( addr, val )
> col, row = addr.upcase.scan( /([A-Z]+)(\d+)/ ).flatten
> data[ index( row, col ) ] = val
> end
>
> m = Matrix.new(%w{A B C}, %w{1 2 3 4})
I would probably not initialize the matrix then. Excel is dynamic as
well. So I'd start with a blank slate and only remember a max value
for row and column.
> m["A1"] = 123
> m["B4"] = 123
>
> I haven't gotten around to changing all the "row, col" to "col, row"
> references, so it looks a bit weird, but I'm just experimenting with
> options at the moment. I'll have a go at Hashing it up as well.
Good. With Ruby, these types of experiments are so much fun. :-)
> Naturally I have many questions floating around in my head, but I'll try
> to work them out through the scientific method of repeated failed
> attempts :)
Actually that's probably the best method to learn: we learn much more
through our failures than from our successes.
Kind regards
robert
--
remember.guy do |as, often| as.you_can - without end
http://blog.rubybestpractices.com/
--
[email protected] |
https://groups.google.com/d/forum/ruby-talk-google?hl=en
---
You received this message because you are subscribed to the Google Groups
"ruby-talk-google" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.