Interval.st
changeset 8374 a5d76d47cc70
parent 7823 4a31fa10c6eb
child 8394 da194de43766
--- a/Interval.st	Mon Jun 07 11:01:04 2004 +0200
+++ b/Interval.st	Mon Jun 07 11:02:59 2004 +0200
@@ -215,6 +215,37 @@
     "
 ! !
 
+!Interval methodsFor:'converting-reindexed'!
+
+from:startIndex
+    "return a new collection representing the receivers elements starting at startIndex."
+
+    step == 1 ifTrue:[
+        ^ start+startIndex-1 to:stop
+    ].
+    "could be more intelligent here"
+    ^ super from:startIndex
+
+    "
+     (1 to:100) from:2  
+
+     (1 to:20 by:2) from:2           
+     (1 to:20 by:2) asArray from:2    
+     ((1 to:20 by:2) from:2) asArray   
+    "
+!
+
+to:endIndex
+    "return a new collection representing the receivers elements upTo and including endIndex."
+
+    ^ start to:(endIndex min:stop) by:step
+
+    "
+     (1 to:100) to:50    
+     (1 to:100 by:2) to:50    
+    "
+! !
+
 !Interval methodsFor:'encoding'!
 
 encodeOn:anEncoder with:aParameter
@@ -516,5 +547,5 @@
 !Interval class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libbasic/Interval.st,v 1.39 2004-01-07 12:51:18 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libbasic/Interval.st,v 1.40 2004-06-07 09:02:59 cg Exp $'
 ! !