aboutsummaryrefslogtreecommitdiff
path: root/tests/pos/Patterns.scala
diff options
context:
space:
mode:
Diffstat (limited to 'tests/pos/Patterns.scala')
-rw-r--r--tests/pos/Patterns.scala15
1 files changed, 14 insertions, 1 deletions
diff --git a/tests/pos/Patterns.scala b/tests/pos/Patterns.scala
index 1161e352b..fbcdc4c30 100644
--- a/tests/pos/Patterns.scala
+++ b/tests/pos/Patterns.scala
@@ -15,5 +15,18 @@ object Patterns {
case Nil => 0
case x :: xs1 => x + sum(xs1)
}
-
+
+ def len[T](xs: List[T]): Int = xs match {
+ case _ :: xs1 => 1 + len(xs1)
+ case Nil => 0
+ }
+
+ final def sameLength[T](xs: List[T], ys: List[T]): Boolean = xs match {
+ case _ :: xs1 =>
+ ys match {
+ case _ :: ys1 => sameLength(xs1, ys1)
+ case _ => false
+ }
+ case _ => ys.isEmpty
+ }
} \ No newline at end of file