diff options
Diffstat (limited to 'src/dotty/tools/package.scala')
-rw-r--r-- | src/dotty/tools/package.scala | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/src/dotty/tools/package.scala b/src/dotty/tools/package.scala index 021e7360b..f23b62862 100644 --- a/src/dotty/tools/package.scala +++ b/src/dotty/tools/package.scala @@ -3,5 +3,18 @@ package dotty package object tools { type FatalError = scala.reflect.internal.FatalError val FatalError = scala.reflect.internal.FatalError - val ListOfNil = List(Nil) + + val ListOfNil = Nil :: Nil + + /** True if two lists have the same length. Since calling length on linear sequences + * is O(n), it is an inadvisable way to test length equality. + */ + 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 + } } |