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]>:
> 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