--- a/Block.st Thu Jul 13 19:03:37 2017 +0200
+++ b/Block.st Thu Jul 13 19:03:56 2017 +0200
@@ -1,5 +1,3 @@
-"{ Encoding: utf8 }"
-
"
COPYRIGHT (c) 1989 by Claus Gittinger
All Rights Reserved
@@ -868,7 +866,7 @@
micros < 1000 ifTrue:[
"/ too stupid: many fonts do not have a mu,
"/ so I output it as us here.
- Transcript show:micros; show:' µs'.
+ Transcript show:micros; show:' µs'.
] ifFalse:[
micros < 100000 ifTrue:[
millis := (micros / 1000.0) asFixedPointRoundedToScale:2.
@@ -3169,6 +3167,34 @@
^ [self valueWithArguments:argArray] newProcess
! !
+!Block methodsFor:'splitting & joining'!
+
+split: aSequenceableCollection indicesDo: aBlock
+ "let me split aSequenceableCollection and evaluate aBlock for each fragment's
+ start- and end-position"
+
+ | position |
+
+ position := 1.
+ aSequenceableCollection withIndexDo:[:element :idx |
+ (self value: element) ifTrue:[
+ aBlock value: position value: idx - 1.
+ position := idx + 1
+ ]
+ ].
+ aBlock value: position value: aSequenceableCollection size
+
+ "
+ [ :char| char isSeparator ] split: 'aa bb cc dd'
+
+ [ :char| char isSeparator ] split: 'aa bb cc dd' do:[:fragment | Transcript showCR:fragment ]
+
+ [ :char| char isSeparator ] split: 'aa bb cc dd' indicesDo:[:start :end | Transcript show:start; show:' to '; showCR:end ]
+ "
+
+ "Created: / 13-07-2017 / 18:32:09 / cg"
+! !
+
!Block methodsFor:'testing'!
isBlock