Indeed :)

Dňa streda, 29. apríla 2015 15:53:53 UTC+2 René Donner napísal(-a):
>
> uh, sorry, the assignment was totally unnecessary of course ;-) 
>
> d = Dict() 
> for i in 1:length(a) 
>     push!( get!(d,a[i],Int[]) ,i) 
> end 
>
>
>
> Am 29.04.2015 um 15:40 schrieb René Donner <[email protected] <javascript:>>: 
>
>
> > Depending on your needs for efficiency and the exact task, this general 
> approach might be ok: 
> > 
> >  a = String["a", "b", "c", "a", "d", "b"] 
> >  d = Dict() 
> >  for i in 1:length(a) 
> >    d[a[i]] = push!(get!(d,a[i],Int[]),i) 
> >  end 
> > 
> > julia> d 
> > Dict{Any,Any} with 4 entries: 
> >  "c" => [3] 
> >  "b" => [2,6] 
> >  "a" => [1,4] 
> >  "d" => [5] 
> > 
> > 
> > Am 29.04.2015 um 15:14 schrieb Ján Dolinský <[email protected] 
> <javascript:>>: 
> > 
> >> Hi, 
> >> 
> >> I am trying to find all duplicates in an iterable collection e.g. of 
> strings. 
> >> 
> >> A = String["a", "b", "c", "a", "d", "b"] 
> >> 
> >> Function unique(A) will return the unique elements. How can I find the 
> remaining duplicates ? I tried setdiff(A, unique(A)) but it works in a 
> different way. 
> >> 
> >> Thanks , 
> >> Jan   
> > 
>
>

Reply via email to