2015年7月15日水曜日

開発環境

Learning Scala: Practical Functional Programming for the JVM (Jason Swartz (著)、O'Reilly Media)のPart Ⅰ. (Core Scala)、Chapter 3.(Expressions and Conditionals)、Exercises 3.(No. 1081)を解いてみる。

その他参考書籍

Exercises 3.(No. 1081)

コード(Emacs)

import scala.io.StdIn.readLine;

var color = readLine(">> ")

while (color != "quit") {
  color match {
    case "cyan" => println("00FFFF")
    case "magenta" => println("FF00FF")
    case "yellow" => println("FFFF00")
    case _ => println("error")
  }
  color = readLine(">> ")
}

入出力結果(Terminal, REPL(Read, Eval, Print, Loop))

$ scala-2.11 sample3.scala
>> cyan
00FFFF
>> magenta
FF00FF
>> yellow
FFFF00
>> red
error
>> quit
$

0 コメント:

コメントを投稿