Hi,
How can I turn and array like this this
[[1,2,3,4,5],[1,2,3,4,5]]
into this
[{:lt=>1,:ln=>1},{:lt=>2,:ln=>2},{:lt=>3,:ln=>3},{:lt=>4,:ln=>4},{:lt=>5,:ln=>5}]
Cheers
--
Posted via http://www.ruby-forum.com/.
|
|
0
|
|
|
|
Reply
|
All4miller
|
4/7/2010 9:24:29 AM |
|
You can try something like that :
a = [[1,2,3,4,5],[1,2,3,4,5]]
a.transpose.collect {|e| {:lt => e.first, :ln => e.last} }
Aurélien AMILIN
Le 07/04/2010 11:24, All4miller All4miller a écrit :
> Hi,
>
> How can I turn and array like this this
>
> [[1,2,3,4,5],[1,2,3,4,5]]
>
> into this
>
> [{:lt=>1,:ln=>1},{:lt=>2,:ln=>2},{:lt=>3,:ln=>3},{:lt=>4,:ln=>4},{:lt=>5,:ln=>5}]
>
> Cheers
>
|
|
0
|
|
|
|
Reply
|
UTF
|
4/7/2010 9:38:12 AM
|
|
thanks that worked great
--
Posted via http://www.ruby-forum.com/.
|
|
0
|
|
|
|
Reply
|
all4
|
4/7/2010 9:56:49 AM
|
|
|
2 Replies
448 Views
(page loaded in 0.454 seconds)
Similiar Articles: Convert multi dimentional array to array of hashes - comp.lang ...You can try something like that : a = [[1,2,3,4,5],[1,2,3,4,5]] a.transpose.collect {|e| {:lt => e.first, :ln => e.last} } Aurélien AMILIN Le 07/04/2010 11 ... vec(.) operator for multidimensional array - comp.soft-sys.matlab ...help needed for a grep in a multidimensional struct array - comp ... Convert multi dimentional array to array of hashes - comp.lang ... vec(.) operator for ... strange - restriction with CLR (.NET)? - comp.lang.c++Convert multi dimentional array to array of hashes - comp.lang ... strange - restriction with CLR (.NET)? - comp.lang.c++ Convert multi dimentional array to array of ... Hierarchical data structure from a multi-dimensional array - comp ...I have a multi-dimensional array representing the column and row ... Splitting into a multi-dimensional array - comp.lang ... to convert a cell array ... array data ... Help rapresenting multidimensional array ( pivot table ) - comp ...-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 On 01/02/10 ... Hierarchical data structure from a multi-dimensional array - comp ..... any help. I have a multi-dimensional ... array of strings - comp.soft-sys.sasConvert all cell array to string - comp.soft-sys.matlab Hi i have a cell array with ... Next: 9.4 Arrays of Pointers Previous Page: 9.2 Implementing Multi-Dimensional Arrays Performance: struct vs. cell array - comp.soft-sys.matlab ...Access multiple structures within cell array - comp.soft-sys ... Splitting into a multi-dimensional ... ... sys.matlab... seconds are required to convert the cell to an array syntax for creating array of cell arrays - comp.soft-sys.matlab ...Splitting into a multi-dimensional array - comp.lang.javascript ... performance array of ... For the record, we need to convert cell array to matrix ... database table of the ... Structure array size 1x1 - comp.soft-sys.matlabHierarchical data structure from a multi-dimensional array - comp ... Structure array ... Convert Cell array to a double array - comp.soft-sys.matlab ... Structure array ... Converting An Iges To A Solidworks Model - Some Advice Please ...Random array? - comp.cad.solidworks I was looking for some advice please: I ... it showing 500 earplugs. The ... Random array? - comp.cad.solidworks Convert multi dimentional ... Convert multi dimentional array to array of hashes - comp.lang ...You can try something like that : a = [[1,2,3,4,5],[1,2,3,4,5]] a.transpose.collect {|e| {:lt => e.first, :ln => e.last} } Aurélien AMILIN Le 07/04/2010 11 ... Data: Multi-dimensional arrays/hashes and slices - Perl 6Data: Multi-dimensional arrays/hashes and slices. VERSION Maintainer: Ilya ... Optionally, a call to tie::multi::inline_ranges() would convert the above list to 7/21/2012 4:01:36 AM
|