X-Git-Url: http://nitlanguage.org diff --git a/lib/standard/collection/range.nit b/lib/standard/collection/range.nit index 882ed1f..1c3e934 100644 --- a/lib/standard/collection/range.nit +++ b/lib/standard/collection/range.nit @@ -11,7 +11,7 @@ # another product. # Module for range of discrete objects. -package range +module range import abstract_collection @@ -42,17 +42,6 @@ class Range[E: Discrete] redef fun iterator do return new IteratorRange[E](self) - redef fun iterate - !each(e: E) - do - var c = _first - var l = _last - while c <= l do - each(c) - c = c.succ - end - end - redef fun length do var nb = _first.distance(_after) @@ -100,3 +89,11 @@ class IteratorRange[E: Discrete] _item = r.first end end + +redef class Discrete + # Returns the range from 0 to `self-1`, is used to do: + # + # for i in 3.times do print "Cool" + # for i in 100.times do print "{i}/100" + fun times: Range[OTHER] do return new Range[OTHER](0, self-1) +end