--- a/Array.st Fri Nov 09 20:55:15 2018 +0100
+++ b/Array.st Fri Nov 09 21:00:40 2018 +0100
@@ -305,7 +305,6 @@
"Modified: 23.4.1996 / 15:55:06 / cg"
! !
-
!Array methodsFor:'accessing'!
at:index
@@ -1428,6 +1427,29 @@
"
!
+recursiveCollect:aBlock
+ "return a copy of the receiver where non-array elements
+ are replaced by whatever aBlock returns,
+ and array elements are recursively processed by this method again.
+ Useful to rewrite ui specs on the fly"
+
+ ^ self collect:[:each |
+ each isArray ifTrue:[
+ each recursiveCollect:aBlock
+ ] ifFalse:[
+ aBlock value:each
+ ]
+ ].
+
+ "
+ #(1 2 3) recursiveCollect:[:el | el == 2 ifTrue:20 ifFalse:el]
+ #(1 2 (1 2 (1 2 (1 2 3) 3) 3) 3) recursiveCollect:[:el | el == 2 ifTrue:20 ifFalse:el]
+ #(1 2 (1 2 (1 2 (1 2 3) 3) 3) 3) recursiveCollect:[:el | el * 2]
+ "
+
+ "Created: / 09-11-2018 / 20:59:58 / Claus Gittinger"
+!
+
reverseDo:aBlock
"evaluate the argument, aBlock for each element in the collection in reverse order.
- reimplemented for speed"