開発環境
- OS X Yosemite - Apple (OS)
- Emacs (Text Editor)
- Scala (プログラミング言語)
Learning Scala: Practical Functional Programming for the JVM (Jason Swartz (著)、O'Reilly Media)のPart Ⅰ. (Core Scala)、Chapter 3.(Expressions and Conditionals)、Exercises 6.(No. 1097)を解いてみる。
その他参考書籍
Exercises 6.(No. 1097)
コード(Emacs)
for (n <- 1 to 100) { if (n % 15 == 0) println("typesafe.") else if (n % 3 == 0) println("type,") else if (n % 5 == 0) println("safe.") else println(n)}
入出力結果(Terminal, REPL(Read, Eval, Print, Loop))
$ scala-2.11 sample6.scala 1 2 type, 4 safe. type, 7 8 type, safe. 11 type, 13 14 typesafe. 16 17 type, 19 safe. type, 22 23 type, safe. 26 type, 28 29 typesafe. 31 32 type, 34 safe. type, 37 38 type, safe. 41 type, 43 44 typesafe. 46 47 type, 49 safe. type, 52 53 type, safe. 56 type, 58 59 typesafe. 61 62 type, 64 safe. type, 67 68 type, safe. 71 type, 73 74 typesafe. 76 77 type, 79 safe. type, 82 83 type, safe. 86 type, 88 89 typesafe. 91 92 type, 94 safe. type, 97 98 type, safe. $
0 コメント:
コメントを投稿