Skip to content

Instantly share code, notes, and snippets.

@parambirs
Created September 5, 2015 06:51
Show Gist options
  • Save parambirs/8f8f1bfe48d4e163439c to your computer and use it in GitHub Desktop.
Save parambirs/8f8f1bfe48d4e163439c to your computer and use it in GitHub Desktop.
Scala insult generator
#!/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