gotcha.
thanks!

On 2 June 2014 16:44, Patrick O'Leary <[email protected]> wrote:

> The iterator for Dict iterates through (key, value) pairs as tuples. Try:
>
> map(dfun, values(d))
>
>
> On Monday, June 2, 2014 10:25:35 AM UTC-5, Florian Oswald wrote:
>>
>> Hi!
>>
>> I want to iterate over a collection of dicts and evaluate a function that
>> takes one Dict at a time. In R-speak I have a list of lists and want to
>> lapply my function - which takes a list as input - for each sublist:
>>
>> function dfun(d::Dict)
>>        println(collect(keys(d)))
>>        println(collect(values(d)))
>>        end
>>
>> # my dict of dicts
>> d = [1 => ["a" => 1.1], 2 => ["b" => 3.12]]
>> [2=>["b"=>3.12],1=>["a"=>1.1]]
>>
>> # works?
>> julia> dfun(d[1])
>> ASCIIString["a"]
>> [1.1]
>>
>> # maps?
>> map(dfun,d)
>> ERROR: no method dfun((Int64,Dict{ASCIIString,Float64}))
>>  in map at abstractarray.jl:1183
>>
>>
>> What's the correct way of doing this? I'm surprised it sends
>> (Int64,Dict{ASCIIString,Float64}) to the funciton and not just
>> Dict{ASCIIString,Float64}
>>
>>

Reply via email to