Packages

Things I didn't want to have to write again.

Current section

Files

Jump to
ex_utils_caddr lib caddr.ex
Raw

lib/caddr.ex

defmodule Caddr do
@moduledoc """
Documentation for Caddr.
"""
@doc """
Hello world.
## Examples
iex> Caddr.uniqc([1,2,3,1,2,3,1,2,4])
%{1 => 3, 2 => 3, 3 => 2, 4 => 1}
"""
def uniqc(e) do
Enum.group_by(e, fn x -> x end)
|> Map.to_list
|> Enum.map(fn {x, y} -> {x, Enum.count(y)} end)
|> Map.new
end
end