Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- defmodule CamelCase do
- def to_camel_case(word) do
- words = String.codepoints(word)
- convert("-", words) |> Enum.join("")
- end
- def convert(a, []) do
- []
- end
- def convert(a, [ a | [h|t] ]) do
- [String.upcase(h) | convert(a, t)]
- end
- def convert(a, [h|t]) do
- [h | convert(a, t)]
- end
- end
- CamelCase.to_camel_case("the-stealth-warrior") |> IO.inspect
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement