Hello,
I have a simple, but very tricky, problem. I would like to fix it using
an array. But matix are possibly more appropriate (even if matrix can
not have 3 dimensional values, I think).
I would like to populate a table (of 2 or 3 dimensions), from a vector.
I think the best way to explain myself is to put some examples, with an
array such as:
# thanks to Rolf Pedersen's function (http://www.ruby-forum.com/topic/208620\)
table = make_array(3, 5)
And now, if the seeder vector is: [1, 0], the result should be:
=> [
=> [4, 3, 2, 1, 0],
=> [4, 3, 2, 1, 0],
=> [4, 3, 2, 1, 0]
=> ]
If the vector is: [-1, 0]
=> [
=> [0, 1, 2, 3, 4],
=> [0, 1, 2, 3, 4],
=> [0, 1, 2, 3, 4]
=> ]
If the vector is: [-2, 0]
=> [
=> [0, 0, 1, 1, 2],
=> [0, 0, 1, 1, 2],
=> [0, 0, 1, 1, 2]
=> ]
If the vector is: [1, 1]
=> [
=> [2, 2, 2, 1, 0],
=> [1, 1, 1, 1, 0],
=> [0, 0, 0, 0, 0]
=> ]
If the vector is: [0, 1]
=> [
=> [2, 2, 2, 2, 2],
=> [1, 1, 1, 1, 1],
=> [0, 0, 0, 0, 0]
=> ]
Have you got a idea, or a plan? :s
Any comments are welcome. Thank you.
Best regards.
···
--
Posted via http://www.ruby-forum.com/\.