Created
August 1, 2014 19:16
-
-
Save bigsnarfdude/9ae01a7df8ffa10b5016 to your computer and use it in GitHub Desktop.
weather.scala video recreation "scala-in-action" talk
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 org.apache.http.client.methods.HttpGet | |
object Weather { | |
private val locations = List( | |
"Berlin,Germany", | |
"Cologne,Germany", | |
"Hamburg,Germany", | |
"Munich,Germany", | |
"Nuremberg,Germany", | |
"Passau,Germany", | |
"Stuttgart,Germany", | |
"Bath,England", | |
"London,England", | |
"Manchester,England", | |
"Dublin,Ireland", | |
"Lille,France", | |
"Marseille,France", | |
"Paris,France", | |
"Boston,USA", | |
"Chicago,USA", | |
"Dallas,USA", | |
"Denver,USA", | |
"Los Angeles,USA", | |
"Miami,USA", | |
"New Orleans,USA", | |
"New York,USA", | |
"San Francisco,USA", | |
"Seattle,USA" | |
) | |
} | |
def main(args: Array[String]): Unit = { | |
val isParallel = arg.headOption map ( _ == "par") getOrElse false | |
val time0 = System.currentTimeMillis | |
val currentTemperatures = | |
(if (isParallel) locations.par else locations) flatmap currentTemperature | |
val time1 = System.currentTimeMillis | |
val averageTemperature = currentTemperature.sum / currentTemperature.size | |
println( | |
s"Calculated avg. temperature of about $averageTemperature C out of ${currentTemperature}" | |
) | |
} | |
def currentTemperature(location: String): Option[Int] = { | |
val uri = (new URIBuilder) | |
} | |
class URIBuilder { | |
??? | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment