Array columns

Hi

I didnt find a method allowing selection of different columns:
[0,1,2,3].atttt(0..1, 3, 2) should give [0,1,3,2]

How can I directly concat n-dimensional arrays?
A=[[1,2],[3,4]]
==> A+A = [[1,2,1,2],[3,4,3,4]]
# analog "abc"+"def"="abcdef"

Thank you
Berg

Hi

I didnt find a method allowing selection of different columns:
[0,1,2,3].atttt(0..1, 3, 2) should give [0,1,3,2]

http://ruby-doc.org/core-2.2.0/Array.html#method-i-values_at

How can I directly concat n-dimensional arrays?
A=[[1,2],[3,4]]
==> A+A = [[1,2,1,2],[3,4,3,4]]
# analog "abc"+"def"="abcdef"

What value of n? For instance, one could reasonably expect A + A = [[2, 4],
[6, 8]] if you keep going till you hit a primitive value, or [A, A] if you
don't drill down at all.

For the specific case of adding an array-of-arrays to itself and stopping
at concatenating the one-dimensional arrays, try a.zip(a).map {|i, j| i + j}

martin

ยทยทยท

On Fri, Feb 19, 2016 at 2:07 PM, A Berger <aberger7890@gmail.com> wrote: