SequenceableCollection>>zip: aCollection
������ | index |
������ index := 0.
������ self size > aCollection size ifTrue:[ ^ aCollection zip: self].
������ ^ self class new: (aCollection size + self size) streamContents: [:stream |
������ ������ ������ aCollection
������ ������ ������ ������ do: [:each | index:=index + 1. stream nextPut: each ]
������ ������ ������ ������ separatedBy: [(index > self size) ifFalse:[stream nextPut: (self at:index) ]]]
Another example, using a generator (I didn't used Generator before, but I like the
idea to create an endless stream from a string, with some fill value (empty string in this case)).
|gen|
gen := Generator on:[:g |�� '123' do:[:k | g yield: k asString ] . [true] whileTrue:[g yield:'']].
String streamContents:[:stream |
������ 'abcdefg' do:[:c | stream nextPut: c]
������ separatedBy:[ stream nextPutAll:gen next]]