Hi Patrick,

Thank you for showing that the dots (...) in Gunnar's solution are 
necessary, it works now:

julia> hcat(A...) 
2x3 Array{Int64,2}: 
1 3 5 
2 4 6

Best,
Bradley



On Sunday, August 24, 2014 10:52:13 AM UTC-5, Patrick O'Leary wrote:
>
> You need to splat (...) A: hcat(A...), in Gunnar's email, vs. hcat(A), in 
> your email. This will supply each element of A as a separate argument to 
> hcat().
>
> Much like the prefix dot for elementwise computation, it's hard to see in 
> a proportional typeface.
>
> On Sunday, August 24, 2014 10:36:29 AM UTC-5, Bradley Setzler wrote:
>>
>> Hi Gunnar,
>>
>> Correct me if I'm wrong, but hcat does not work for Any types. I'm 
>> looking for a version of hcat that works with Any.
>>
>> We have A:
>>
>> julia> A 
>> 3-element Array{Any,1}: 
>> [1,2] 
>> [3,4] 
>> [5,6] 
>>
>> We want B:
>>
>> julia> B 
>> 2x3 Array{Int64,2}: 
>> 1 3 5 
>> 2 4 6 
>>
>> So we try hcat(A) but it fails to return B:
>>
>> julia> hcat(A) 
>> 3x1 Array{Any,2}: 
>> [1,2] 
>> [3,4] 
>> [5,6]
>>
>>
>> Thanks,
>> Bradley
>>
>>
>>
>> On Sunday, August 24, 2014 4:01:25 AM UTC-5, Gunnar Farnebäck wrote:
>>>
>>> For maximum efficiency Diego's loop solution is likely best but for 
>>> succinctness, try hcat(A...).
>>>
>>> Den lördagen den 23:e augusti 2014 kl. 04:05:19 UTC+2 skrev Bradley 
>>> Setzler:
>>>>
>>>> Good evening,
>>>>
>>>> I often have Any types filled with vectors (especially as the return of 
>>>> a pmap), and need them as a matrix or DataFrame. For example, suppose I 
>>>> have,
>>>>
>>>> julia> A
>>>> 3-element Array{Any,1}: 
>>>> [1,2] 
>>>> [3,4] 
>>>> [5,6]
>>>>
>>>> But I want,
>>>>
>>>> julia> B
>>>> 2x3 Array{Int64,2}: 
>>>> 1 3 5 
>>>> 2 4 6
>>>>
>>>> I came up with the following, which successfully constructs B from A, 
>>>> but it's a bit inefficient/messy:
>>>>
>>>> B = A[1]
>>>> for i=2:length(A)
>>>>     B = hcat(B,A[i])
>>>> end
>>>>
>>>> Is there a better way to do this? Something like,
>>>> julia> B = hcatForAny(A)
>>>>
>>>> Thanks,
>>>> Bradley
>>>>
>>>>

Reply via email to