On Tue, Jul 14, 2015 at 7:09 PM, Ritchie Lee <[email protected]> wrote:
> Sorry if this is a newbie question. I am trying to get map() to work with
> with enumerate() but I am getting an error.
>
> r=rand(5)
> map((i,v)->i+v, enumerate(r))
> ERROR: wrong number of arguments
> in anonymous at none:1
> in map at abstractarray.jl:1207
>
> collect(enumerate(r)) generates an array of 2-tuples as expected.
`map` does not splat each element of the iteration and only pass each
element as a single argument to the function
```julia
julia> r = rand(5)
map(x->((i, v) = x; i + v), enumerate(r))
5-element Array{Any,1}:
1.6277
2.41751
3.34848
4.70194
5.89139
```
>
> Is the syntax incorrect?
>
> Thanks,
>
> Ritchie