--- a/Interval.st Sat Feb 18 02:42:00 1995 +0100
+++ b/Interval.st Sat Feb 18 19:30:27 1995 +0100
@@ -21,7 +21,7 @@
COPYRIGHT (c) 1989 by Claus Gittinger
All Rights Reserved
-$Header: /cvs/stx/stx/libbasic/Interval.st,v 1.11 1995-02-02 12:21:18 claus Exp $
+$Header: /cvs/stx/stx/libbasic/Interval.st,v 1.12 1995-02-18 18:29:18 claus Exp $
'!
!Interval class methodsFor:'documentation'!
@@ -42,14 +42,15 @@
version
"
-$Header: /cvs/stx/stx/libbasic/Interval.st,v 1.11 1995-02-02 12:21:18 claus Exp $
+$Header: /cvs/stx/stx/libbasic/Interval.st,v 1.12 1995-02-18 18:29:18 claus Exp $
"
!
documentation
"
Intervals represent a collection (or range) of numeric values specified by
- a startValue, an endValue and a step. The elements are computed, not stored.
+ a startValue, an endValue and a step.
+ The interresting thing is that the elements are computed, not stored.
For example, the interval (1 to:5) containes the elements (1 2 3 4 5) and
(1 to:6 by:2) contains (1 3 5).
"
@@ -185,10 +186,6 @@
!Interval methodsFor:'printing & storing'!
-XXdisplayString
- ^ 'Interval(' , self printString , ')'
-!
-
printOn:aStream
"append a printed representation to aStream"
@@ -200,9 +197,11 @@
step printOn:aStream.
].
- "(1 to:10) printOn:Transcript"
- "(1 to:10 by:2) printOn:Transcript"
- "(1 to:10) printString"
+ "
+ (1 to:10) printOn:Transcript
+ (1 to:10 by:2) printOn:Transcript
+ (1 to:10) printString
+ "
!
storeOn:aStream
@@ -212,15 +211,19 @@
self printOn:aStream.
aStream nextPut:$).
- "(1 to:10) storeOn:Transcript"
- "(1 to:10 by:2) storeOn:Transcript"
+ "
+ (1 to:10) storeOn:Transcript
+ (1 to:10 by:2) storeOn:Transcript
+ "
! !
!Interval methodsFor:'enumerating'!
do:aBlock
"evaluate the argument, aBlock for every element in the
- receiver-interval"
+ receiver-interval.
+ Redefined since SeqColl accesses the receiver with at:, which is
+ slow for intervals."
|aValue|
@@ -241,7 +244,7 @@
select:aBlock
"evaluate the argument, aBlock for every element in the collection
and return a collection of all elements for which the block return
- true. redefined since SeqColl accesses the receiver with at:, which is
+ true. Redefined since SeqColl accesses the receiver with at:, which is
slow for intervals."
|newColl|
@@ -251,11 +254,15 @@
(aBlock value:each) ifTrue:[newColl add:each]
].
^ newColl
+
+ "
+ (1 to:20) select:[:i | i even]
+ "
!
collect:aBlock
"evaluate the argument, aBlock for every element in the collection
- and return a collection of the results - redefined since SeqColl
+ and return a collection of the results - Redefined since SeqColl
accesses the receiver via at:, which is slow for intervals"
|newCollection|
@@ -265,4 +272,8 @@
newCollection add:(aBlock value:each)
].
^ newCollection
+
+ "
+ (1 to:20) collect:[:i | i*i]
+ "
! !