Re: [julia-users] Converting vectors to dictionaries back and forth

2015-09-01 Thread Cedric St-Jean
BTW, if I'm not mistaken, your dict_to_vec function can be written as just collect(values(d)). On Tuesday, September 1, 2015 at 9:47:47 AM UTC-4, ami...@gmail.com wrote: > > Exactly what I needed, thanks a lot. >

Re: [julia-users] Converting vectors to dictionaries back and forth

2015-09-01 Thread amiksvi
Exactly what I needed, thanks a lot.

Re: [julia-users] Converting vectors to dictionaries back and forth

2015-09-01 Thread Yichao Yu
On Tue, Sep 1, 2015 at 9:39 AM, wrote: > Hi, > > I want to be able to convert vectors to dictionaries and the other way > round. I have coded these two functions: > > function vec_to_dict(v, ll) > d = Dict() > assert(length(v) == length(ll)) > for i = 1:length(v) > d[ll[i]] =

[julia-users] Converting vectors to dictionaries back and forth

2015-09-01 Thread amiksvi
Hi, I want to be able to convert vectors to dictionaries and the other way round. I have coded these two functions: function vec_to_dict(v, ll) d = Dict() assert(length(v) == length(ll)) for i = 1:length(v) d[ll[i]] = v[i] end return d end function dict_to_vec(d)