I have an array and I want to merge it.
This is the array:
let numbers = [ [ 1, 2, 3 ], [ 4, 5, 6 ] ]
I need a output like this:
let result = [ [ 1, 4 ], [ 2, 5 ], [ 3, 6 ] ]
I have an array and I want to merge it.
This is the array:
let numbers = [ [ 1, 2, 3 ], [ 4, 5, 6 ] ]
I need a output like this:
let result = [ [ 1, 4 ], [ 2, 5 ], [ 3, 6 ] ]
2
Answers
You can use the zip global function, which, given 2 sequences, returns a sequence of tuples and then obtain an array of tuples by using the proper init.
And then you can access the tuples like this :
If the array has more elements the following would work.