diff options
author | Adriaan Moors <adriaan.moors@typesafe.com> | 2013-12-09 11:06:22 -0800 |
---|---|---|
committer | Adriaan Moors <adriaan.moors@typesafe.com> | 2013-12-09 17:11:05 -0800 |
commit | e55510607031aaf7b8473453f83c44a26c9b97e0 (patch) | |
tree | 987d4aeeef387ed435acc64ffadfdf78e6f65bce /docs/examples/patterns.scala | |
parent | dc6dd58d9da441b591580684f3d2f38d7898e7d4 (diff) | |
download | scala-e55510607031aaf7b8473453f83c44a26c9b97e0.tar.gz scala-e55510607031aaf7b8473453f83c44a26c9b97e0.tar.bz2 scala-e55510607031aaf7b8473453f83c44a26c9b97e0.zip |
Remove docs/examples; they reside at scala/scala-dist
Diffstat (limited to 'docs/examples/patterns.scala')
-rw-r--r-- | docs/examples/patterns.scala | 36 |
1 files changed, 0 insertions, 36 deletions
diff --git a/docs/examples/patterns.scala b/docs/examples/patterns.scala deleted file mode 100644 index 738deabc66..0000000000 --- a/docs/examples/patterns.scala +++ /dev/null @@ -1,36 +0,0 @@ -package examples - -object patterns { - - trait Tree - case class Branch(left: Tree, right: Tree) extends Tree - case class Leaf(x: Int) extends Tree - - val tree1 = Branch(Branch(Leaf(1), Leaf(2)), Branch(Leaf(3), Leaf(4))) - - def sumLeaves(t: Tree): Int = t match { - case Branch(l, r) => sumLeaves(l) + sumLeaves(r) - case Leaf(x) => x - } - - def find[a,b](it: Iterator[Pair[a, b]], x: a): Option[b] = { - var result: Option[b] = None - var found = false - while (it.hasNext && !found) { - val Pair(x1, y) = it.next - if (x == x1) { found = true; result = Some(y) } - } - result - } - - def printFinds[a](xs: List[Pair[a, String]], x: a) = - find(xs.iterator, x) match { - case Some(y) => System.out.println(y) - case None => System.out.println("no match") - } - - def main(args: Array[String]) { - println("sum of leafs=" + sumLeaves(tree1)) - printFinds(List(Pair(3, "three"), Pair(4, "four")), 4) - } -} |