Your anonymous function expects two scalar arguments, not one tuple
argument. You need to write instead:

```Julia
map(t -> ((x,y) = t; x+y), [(1,1),(2,2)])
```

This is a function accepting one tuple `t`, which is then decomposed into
its elements `x,y` via an assignment.

-erik



On Sun, Jul 17, 2016 at 9:00 AM, Jesse Jaanila <jessejaan...@gmail.com>
wrote:

> Hi,
>
> I'm trying to map a array of tuples.
>
> julia> map((x,y) -> x+y, [(1,1),(2,2)])
> ERROR: wrong number of arguments
>  in anonymous at none:1
>  in map at abstractarray.jl:1305
>
> This doesn't work. I expect the result to be
> [2,4]
>
> Can this kind of mapping be achieved or the map function only defined for
> one dimensional domain i.e. Array{T, 1}?
>
>


-- 
Erik Schnetter <schnet...@gmail.com>
http://www.perimeterinstitute.ca/personal/eschnetter/

Reply via email to