Lazy.jl has a version of this called `frequencies`, but I just tried it and
turns out it's broken. Here's the (fixed) source:

function frequencies(xs)
  freqs = Dict{eltype(xs),Int}()
  for x in xs
    freqs[x] = get(freqs, x, 0) + 1
  end
  return freqs
end

On 26 March 2015 at 21:11, DumpsterDoofus <[email protected]>
wrote:

> In Mathematica, there is a function called Tally which takes a list and
> returns a list of the unique elements of the input list, along with their
> multiplicities. I.e, it takes a list of length N and returns an array of
> dimensions (N,2), namely the pairs of elements and the number of times they
> appear.
>
> Is there a similar (but perhaps differently-named) function in Julia to
> tally a list?
>

Reply via email to