文章分类 -  programming

摘要:# `msort` vs `sortWith`~~~scalaval ls = List("a", "b", "c", "d", "e")msort((x: Char, y: Char) => x > y)(ls)ls sortWith(_ > _)msort(_ > _)(ls) // er... 阅读全文
posted @ 2015-05-20 17:37 alfonso 阅读(163) 评论(0) 推荐(0)
摘要:# Case Class and Pattern Matching## A simple example~~~scalaabstract class Exprcase class Var(name: String) extends Exprcase class Number(name: Double... 阅读全文
posted @ 2015-05-15 14:34 alfonso 阅读(249) 评论(0) 推荐(0)
摘要:# TraitsTraits are a fundamental unit of code reuse in Scala. A trait encapsulates method and field definitions, which can then be reused by mixing th... 阅读全文
posted @ 2015-05-15 14:33 alfonso 阅读(136) 评论(0) 推荐(0)
摘要:## 特殊之处In Scala assignment always results in the unit value, ()```scalavar a = 1(a = 2).getClass //=> Class[Unit] = void```## 读取文件```scalaimport s... 阅读全文
posted @ 2015-05-15 14:32 alfonso 阅读(127) 评论(0) 推荐(0)
摘要:## Composition and Inheritance1. abstract classes2. parameterless methods3. extending classes4. overriding methods and fields5. parametric fields6. in... 阅读全文
posted @ 2015-05-15 14:32 alfonso 阅读(100) 评论(0) 推荐(0)
摘要:# 4.1 Computational EffectsThe *value* produced by a computation may have *effects* as well: it may read,print,or alter the state of memory or a file ... 阅读全文
posted @ 2015-05-11 21:38 alfonso 阅读(149) 评论(0) 推荐(0)