Thanks for the feedback!
np
I simply thought it would be nice if you can address elements simply as:
A[i, j, k ...]
true, it'd be nice but it kinda wont work... (see next)
> uhm...i'm not sure what your trying to do with this, but what if i
> wanted to
> get the 5th element in the 4th dimension?
Wouldn't that simply be dc[0,0,0,5]?
no, that wont work. try your code in irb, with your 3x5 data cube...
irb(main):055:0* dc = DataCube.new(3, 5)
=> [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0]
irb(main):056:0> dc[0,1,2]=44
=> 44
irb(main):057:0> puts dc[0, 1, 2]
44
=> nil
irb(main):058:0> puts dc.size
125
=> nil
irb(main):059:0> dc
=> [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 44, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0]
thats the actual representation of the data cube in your computer. i'm not
sure that's exactly what you want, but it dosnt really look right to me.
i dunno, mabye you are right and this is just a funky way to do this, i'll
take a longer look a little later, but now PIZZA!!
hex
(yes, pizza is more important than you :P)
···
>
> i'd write the generator method something like this:
>
> while i < @n
> j = 0
> while j < @m
> @array[[i]] << 0
> j += 1
> end
> i += 1
> end
>
> (i havnt tested it, so it may not work)
>
> then you'd need to define the other accessor methods & such... but
> thats a
> start
>
> hex
--
Posted via http://www.ruby-forum.com/\.