Created
September 5, 2015 06:51
-
-
Save parambirs/8f8f1bfe48d4e163439c to your computer and use it in GitHub Desktop.
Scala insult generator
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
#!/usr/bin/env scala | |
import scala.collection.immutable.IndexedSeq | |
val alphabets = 'A' to 'Z' | |
val insult = if(args.length > 0) args(0).toUpperCase else "STUPID" | |
val heading = alphabets filterNot (insult contains(_)) | |
println(getInsult) | |
def getInsult() = { | |
s""" | |
| ${spaced(heading)} | |
| | |
| "You must be wondering what happened to the rest of the letters" | |
| | |
| | |
| | |
| "They are written below" | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| . | |
| . | |
| . | |
| | |
| | |
| ${spaced(insult)} | |
""".stripMargin | |
} | |
def spaced(str: IndexedSeq[Char]) = str.mkString(" ") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment