Skip to content

Instantly share code, notes, and snippets.

@mvelebit
Created October 17, 2019 15:06
Show Gist options
  • Save mvelebit/6811bd7e83a06efe2e416adfc88cee16 to your computer and use it in GitHub Desktop.
Save mvelebit/6811bd7e83a06efe2e416adfc88cee16 to your computer and use it in GitHub Desktop.
Convert normal text into that succulent SpongeBob chicken meme format
def toChickenCase(text: Seq[Char], soFar: List[Char] = List.empty, wasLastUpper: Boolean = false): String = text.toList match {
case h :: t =>
val shouldUpper = !wasLastUpper
val newList = if (shouldUpper) soFar :+ Character.toUpperCase(h) else soFar :+ h
toChickenCase(t, newList, shouldUpper)
case _ => soFar.mkString
}
toChickenCase("Our engineers have reviewed your code and they deemed it unworthy.")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment