A friend of mine who is learning Elixir asked me how I would write a function
that takes a length
n and a char
c to build a string consisting of
iex and messing around with it brings me up to the conclusion - easy:
Stream.repeatedly(fn -> "-" end) |> Stream.take(10) |> Enum.join("")
Wow, so Clojure. Nothing wrong with that, but the said friend rated it ugly.
Then I figured
Which made me angry enough to look up
@spec duplicate(t, non_neg_integer) :: t def duplicate(subject, n) when is_integer(n) and n >= 0 do :binary.copy(subject, n) end
Duh. All hail Erlang.