Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
def camelize(""),
do: ""
def camelize(<<?_, t :: binary>>),
do: camelize(t)
def camelize(<<h, t :: binary>>),
do: <<to_upper_char(h)>> <> do_camelize(t)
defp do_camelize(<<?_, ?_, t :: binary>>),
do: do_camelize(<< ?_, t :: binary >>)
defp do_camelize(<<?_, h, t :: binary>>) when h in ?a..?z,
do: <<to_upper_char(h)>> <> do_camelize(t)
defp do_camelize(<<?_>>),
do: <<>>
defp do_camelize(<<?/, t :: binary>>),
do: <<?.>> <> camelize(t)
defp do_camelize(<<h, t :: binary>>),
do: <<h>> <> do_camelize(t)
defp do_camelize(<<>>),
do: <<>>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment