--- a/Collection.st Mon Jan 21 10:31:25 2019 +0100
+++ b/Collection.st Mon Jan 21 13:15:04 2019 +0100
@@ -3640,6 +3640,28 @@
"Created: 9.5.1996 / 00:58:24 / cg"
!
+keysAndValuesSelect:selectBlockWith2Args
+ "first call the selectBlockWith2Args, passsing it each key and element,
+ collect the elements for which the block returns true in an OrderedCollection."
+
+ |collected|
+
+ collected := OrderedCollection new.
+ self keysAndValuesDo:[:eachKey :eachValue |
+ (selectBlockWith2Args value:eachKey value:eachValue) ifTrue:[
+ collected add:eachValue
+ ].
+ ].
+ ^ collected
+
+ "
+ #(10 20 30 40)
+ keysAndValuesSelect:[:idx :val | idx odd]
+ "
+
+ "Created: / 21-01-2019 / 13:14:30 / Claus Gittinger"
+!
+
keysAndValuesSelect:selectBlockWith2Args thenCollect:collectBlockWith2Args
"first call the selectBlockWith2Args, passsing it each key and element,
if that returns true, call the collectBlockWith2Args, also with key and element,