Skip to content

Instantly share code, notes, and snippets.

@darkfrog26
Last active August 29, 2015 14:11
Show Gist options
  • Save darkfrog26/9e50d9385a6de2a9d889 to your computer and use it in GitHub Desktop.
Save darkfrog26/9e50d9385a6de2a9d889 to your computer and use it in GitHub Desktop.
import scala.collection.mutable.ListBuffer
import scala.io.Source
import scala.util.Random
/**
* @author Matt Hicks <matt@outr.com>
*/
object Test {
def main(args: Array[String]): Unit = {
var quotes = ListBuffer.empty[String]
Source.fromURL("http://www.coverfire.com/files/quotes.txt").getLines().foldLeft("")((aggregate, current) => if (current.trim.isEmpty) { quotes += aggregate.trim; "" } else { s"$aggregate\r\n$current" })
println(quotes(Random.nextInt(quotes.length - 1)))
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment