RosettaCodeData/Task/Sparkline-in-unicode/Elixir/sparkline-in-unicode-1.elixir

9 lines
267 B
Text
Raw Permalink Normal View History

2015-02-20 09:02:09 -05:00
defmodule RC do
def sparkline(str) do
values = str |> String.split(~r/(,| )+/)
2016-12-05 22:15:40 +01:00
|> Enum.map(&elem(Float.parse(&1), 0))
{min, max} = Enum.min_max(values)
2015-02-20 09:02:09 -05:00
IO.puts Enum.map(values, &(round((&1 - min) / (max - min) * 7 + 0x2581)))
end
end