Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- defmodule Frequent do
- def number( [num | tail] ) do
- number({num, 1}, tail, {num, 1})
- end
- def number({num, count}, [ num | tail ], max) do
- number({num, count + 1}, tail, max)
- end
- def number({_num, count} = current, [ diff | tail ], {_, max_count} = max) do
- if count > max_count do
- max = current
- end
- number({diff, 1}, tail, max)
- end
- def number(_, [], max), do: max
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement