From b0bcd0a40d209e02cd8bbabedc5819f6ce8108ef Mon Sep 17 00:00:00 2001 From: Lukas Rytz Date: Tue, 10 Feb 2009 09:32:05 +0000 Subject: fix for #1691 --- src/library/scalax/collection/immutable/List.scala | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'src/library/scalax') diff --git a/src/library/scalax/collection/immutable/List.scala b/src/library/scalax/collection/immutable/List.scala index bed0ab96f5..6851fb9769 100644 --- a/src/library/scalax/collection/immutable/List.scala +++ b/src/library/scalax/collection/immutable/List.scala @@ -589,7 +589,9 @@ object List extends SequenceFactory[List] { * @deprecated use @see iterate instead. * @param start the start value of the list * @param end the end value of the list - * @param step the increment function of the list, must be monotonically increasing or decreasing + * @param step the increment function of the list, which given vn, + * computes vn+1. Must be monotonically increasing + * or decreasing. * @return the sorted list of all integers in range [start;end). */ @deprecated def range(start: Int, end: Int, step: Int => Int): List[Int] = { @@ -599,7 +601,10 @@ object List extends SequenceFactory[List] { var i = start while ((!up || i < end) && (!down || i > end)) { b += i - i += step(i) + val next = step(i) + if (i == next) + throw new IllegalArgumentException("the step function did not make any progress on "+ i) + i = next } b.toList } -- cgit v1.2.3