Last active
August 29, 2015 14:11
-
-
Save darkfrog26/9e50d9385a6de2a9d889 to your computer and use it in GitHub Desktop.
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
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