Last active
February 12, 2017 13:52
-
-
Save MQuy/b485cb84e98dbe6e0d48c569b8f4f8f7 to your computer and use it in GitHub Desktop.
ElixirVN - Exercise
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
defmodule App do | |
def split_case(str), do: split_case(str, [[], []]) | |
def split_case(<<char, remain :: binary>>, [upper, lower]) when char < 97 do | |
split_case(remain, [[upper, char], lower]) | |
end | |
def split_case(<<char, remain :: binary>>, [upper, lower]) do | |
split_case(remain, [upper, [lower, char]]) | |
end | |
def split_case("", [upper, lower]) do | |
[ | |
IO.iodata_to_binary(upper), | |
IO.iodata_to_binary(lower) | |
] | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment