--- a/Collection.st Thu Jun 23 16:55:10 2011 +0100
+++ b/Collection.st Thu Jul 07 23:08:07 2011 +0100
@@ -259,7 +259,6 @@
^ self withSize:n
! !
-
!Collection class methodsFor:'Signal constants'!
emptyCollectionSignal
@@ -480,7 +479,6 @@
].
! !
-
!Collection methodsFor:'accessing'!
anElement
@@ -2581,6 +2579,28 @@
"
!
+with:aCollection contains:aTwoArgBlock
+ "evaluate the argument, aBlock for successive elements from
+ each the receiver and the argument, aCollection.
+ Return true, if the block returns true for any of these pairs.
+ This method fails if neither the receiver nor aCollection is
+ a sequenceable collection (i.e. implements numeric key access)."
+
+ self with:aCollection do:[:a :b |
+ (aTwoArgBlock value:a value:b) ifTrue:[^ true].
+ ].
+ ^ false.
+
+ "
+ (1 to:3) with:#(1 2 3 4) contains:[:a :b | a ~= b] --- raises an error
+ (1 to:3) with:#(1 22 3) contains:[:a :b | a ~= b]
+ (1 to:3) with:#(1 2 3) contains:[:a :b | a ~= b]
+ "
+
+ "Created: / 30-06-2011 / 12:37:41 / cg"
+ "Modified (Format): / 30-06-2011 / 12:40:38 / cg"
+!
+
with:aCollection count:aTwoArgBlock
"evaluate the argument, aBlock for successive elements from
each the receiver and the argument, aSequenceableCollection.
@@ -2608,10 +2628,15 @@
each the receiver and the argument, aSequenceableCollection.
The second argument, aBlock must be a two-argument block.
This method fails if neither the receiver nor aCollection is
- a sequenceable collection (i.e. implements numeric key access)."
+ a sequenceable collection (i.e. implements numeric key access)
+ or (new!!) if the sizes are different."
|index "{ Class: SmallInteger }"|
+ aCollection size == self size ifFalse:[
+ NotEnoughElementsSignal raiseRequestErrorString:'collections must be of the same size'.
+ ].
+
index := 1.
aCollection isSequenceable ifFalse:[
self isSequenceable ifFalse:[
@@ -2639,6 +2664,8 @@
Transcript showCR:(num->sym)
]
"
+
+ "Modified: / 30-06-2011 / 17:39:47 / cg"
! !
!Collection methodsFor:'enumerating-tests'!
@@ -3950,27 +3977,8 @@
!Collection class methodsFor:'documentation'!
-version
- ^ '$Id: Collection.st 10643 2011-06-08 21:53:07Z vranyj1 $'
-!
-
version_CVS
- ^ 'Header: /cvs/stx/stx/libbasic/Collection.st,v 1.257 2011/04/13 16:10:00 cg Exp '
-!
-
-version_SVN
- ^ '$Id: Collection.st 10643 2011-06-08 21:53:07Z vranyj1 $'
+ ^ '§Header: /cvs/stx/stx/libbasic/Collection.st,v 1.259 2011/06/30 15:40:16 cg Exp §'
! !
-Collection initialize!
-
-
-
-
-
-
-
-
-
-
-
+Collection initialize!
\ No newline at end of file