baptiste Auguié
7/4/2007 12:48:00 PM
Hi,
I'm trying to do a simple thing : access elements of a vector
specified by their index. In Matlab/Octave i would do,
newVector=oldVector( [1, 3, 56, 72] )
How does this work with Ruby vectors?
oldVector.get(3,4,5) returns the first 3 elements, where I would
expect the 2nd, 3d and 4th.
I've had to do a twisted version of this using arrays and lists,
a2=[]
(0..200).step(10) {|i| a2 << a[i] }
I find it very inefficient and annoying, plus I do need to use
vectors rather than arrays and lists and do not really know how to
convert between these three :(
Oh, and just a quick question: how can i do two instructions in one
block ? I have to repeat the same instructions over and over like
shown below...
a2=[]
b2=[]
(0..200).step(10) {|i| a2 << a[i] }
(0..200).step(10) {|i| b2 << b[i] }
Best regards,
baptiste