I don't think it is the problem of (+). Since

julia> map((x...)->x,(1,2),(3,4),(5,6))
ERROR: BoundsError()
 in heads at tuple.jl:56
 in map at tuple.jl:59 (repeats 3 times)

has the same problem. I think the expected result should be 
((1,3,5),(2,4,6)).

also, 
julia> map((x...)->x,[1,2],[3,4],[5,6])
2-element Array{(Int64,Int64,Int64),1}:
 (1,3,5)
 (2,4,6)

On Tuesday, September 2, 2014 3:24:39 PM UTC+2, Elliot Saba wrote:
>
> Addition doesn't seem to be defined for tuples:
>
> julia> (1,2,3) + (4,5,6)
> ERROR: `+` has no method matching +(::(Int64,Int64,Int64), 
> ::(Int64,Int64,Int64))
>
>
> The BoundsError is quite misleading however. Not sure what it's really 
> doing in there.  Tuples are pretty separated from arrays in Julia however, 
> in other languages such as Python I see tuples and lists used 
> interchangeably quite a bit, however in Julia the most common usage of 
> tuples I've found are in metaprogramming (collecting function arguments and 
> the like).  If you want to perform algebraic operations you should be using 
> Arrays that contain well defined types.  This is, after all, one reason 
> Julia is able to achieve high speeds; if Julia knows that every element in 
> your array is an Int64, or a Float32 or whatever you like, then an 
> operation such as you have above can be performed very quickly without 
> performing type-checking on each individual element in your array.
> -E
>
>
> On Tue, Sep 2, 2014 at 8:49 AM, <[email protected] <javascript:>> wrote:
>
>> julia> versioninfo()
>> Julia Version 0.4.0-dev+323
>> Commit ecd039c* (2014-08-24 16:57 UTC)
>> Platform Info:
>>   System: Linux (x86_64-redhat-linux)
>>   CPU: Intel(R) Xeon(R) CPU E7- 4830  @ 2.13GHz
>>   WORD_SIZE: 64
>>   BLAS: libopenblas (USE64BITINT NO_AFFINITY NEHALEM)
>>   LAPACK: libopenblas
>>   LIBM: libopenlibm
>>   LLVM: libLLVM-3.3
>>
>> julia> map((x,y,z)->x+y+z,[1,2,3],[2,3,4],[3,4,5])
>> 3-element Array{Int64,1}:
>>   6
>>   9
>>  12
>>
>> julia> map((x,y,z)->x+y+z,(1,2,3),(2,3,4),(3,4,5))
>> ERROR: BoundsError()
>>  in heads at tuple.jl:56
>>  in map at tuple.jl:59 (repeats 4 times)
>>
>>
>>
>>
>

Reply via email to