Created
October 17, 2019 15:06
-
-
Save mvelebit/6811bd7e83a06efe2e416adfc88cee16 to your computer and use it in GitHub Desktop.
Convert normal text into that succulent SpongeBob chicken meme format
This file contains 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
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