Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Scalaをはじめる α

Scalaをはじめる α

Tomohiko Himura

June 06, 2015
Tweet

More Decks by Tomohiko Himura

Other Decks in Programming

Transcript

  1. ͜Μͺ͍Δͯ͠ɻ $ cat HelloCompile.scala object HelloCompile { def main(args: Array[String])

    = println(“Hello, Z”) } $ scalac HelloCompile.scala $ scala HelloCompile Hello, Z
  2. TDBMB[Λ͔ͭͬͯΈΔɻ $ scala -version Scala code runner version 2.11.6 --

    Copyright 2002-2013, LAMP/EPFL $ curl -O https://repo1.maven.org/maven2/org/scalaz/ scalaz-core_2.11/7.1.2/scalaz-core_2.11-7.1.2.jar $ scala -cp scalaz-core_2.11-7.1.2.jar > import scalaz.Scalaz._ val hello = (str: String) => "Hello, " + str val z = (str: Option[String]) => str.getOrElse("Z") (hello <<< z)(None) // => "Hello, Z” (hello <<< z)(Some(“World”)) // => “Hello, World”
  3. TDBMB[Λ͔ͭͬͯΈΔɻ $ scala -version Scala code runner version 2.11.6 --

    Copyright 2002-2013, LAMP/EPFL $ curl -O https://repo1.maven.org/maven2/org/scalaz/ scalaz-core_2.11/7.1.2/scalaz-core_2.11-7.1.2.jar $ scala -cp scalaz-core_2.11-7.1.2.jar > import scalaz.Scalaz._ val hello = (str: String) => "Hello, " + str val z = (str: Option[String]) => str.getOrElse("Z") (hello <<< z)(None) // => "Hello, Z” (hello <<< z)(Some(“World”)) // => “Hello, World”
  4. ͜Μͺ͍Δͯ͠ΈΔɻ $ cat HelloZ.scala import scalaz.Scalaz._ class Hello extends App

    { val hello = (str: String) => "Hello, " + str val z = (str: Option[String]) => str.getOrElse("Z") println((hello <<< z)(args.headOption)) } $ scalac -cp scalaz-core_2.11-7.1.2.jar HelloZ.scala $ scala -cp scalaz-core_2.11-7.1.2.jar:. HelloZ Hello, Z $ scala -cp scalaz-core_2.11-7.1.2.jar:. HelloZ World Hello, World
  5. ͜Μͺ͍Δͯ͠ΈΔɻ $ cat HelloZ.scala import scalaz.Scalaz._ class Hello extends App

    { val hello = (str: String) => "Hello, " + str val z = (str: Option[String]) => str.getOrElse("Z") println((hello <<< z)(args.headOption)) } $ scalac -cp scalaz-core_2.11-7.1.2.jar HelloZ.scala $ scala -cp scalaz-core_2.11-7.1.2.jar:. HelloZ Hello, Z $ scala -cp scalaz-core_2.11-7.1.2.jar:. HelloZ World Hello, World