I've been meaning to add methods for mapping over Dicts forever and just haven't done it yet. Seems like a good opportunity for a first pull request, if you feel like it, Fil :-)
On Thu, Feb 13, 2014 at 12:52 AM, Fil Mackay <[email protected]>wrote: > Thanks Jake, is there an elegant way to produce a Dict instead of an Array? > > This would need a specific implementation for map() for Dict, yes? > > On Thu, Feb 13, 2014 at 3:28 PM, Jake Bolewski <[email protected]>wrote: > >> you can iterate over a dict >> >> julia> methods(map) >> ... lots of methods >> map(f::Union(Function,DataType),iters...) at abstractarray.jl:1264 >> >> which will return a tuple of (key, value) >> >> julia> map( kv -> kv, {1=>"foo", 2=>"bar"}) >> 2-element Array{Any,1}: >> (2,"bar") >> (1,"foo") >> >> since you can map over arbitrary number of iterables. >> >> julia> let d = {1=>"foo", 2=>"bar"} >> map( (k, v) -> (k, v), keys(d), values(d)) >> end >> 2-element Array{Any,1}: >> (2,"bar") >> (1,"foo") >> >>
