Skip to content

Instantly share code, notes, and snippets.

@bigsnarfdude
Created August 1, 2014 19:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bigsnarfdude/9ae01a7df8ffa10b5016 to your computer and use it in GitHub Desktop.
Save bigsnarfdude/9ae01a7df8ffa10b5016 to your computer and use it in GitHub Desktop.
weather.scala video recreation "scala-in-action" talk
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