The following method in class Generator produces a sequence consisting of the first $n$ elements of the underlying generator, where $n$ is the integer argument.
first: limit $\quad$ | counter testBlock $\mid$
testBlock $\leftarrow[: x \mid$ counter $\leftarrow$ counter +1.
(counter $>$ limit)
iffalse: $[x]]$.
$\uparrow$ AbstractGenerator new $;$
firstBlock: [ counter $\leftarrow 0$.
testBlock value: self first ]
nextBlock: [ testBlock value: self next ]
first: limit $\quad \mid$ counter testBlock $\mid$
testBlock $\leftarrow[: x \mid$ counter $\leftarrow$ counter +1.
(counter $>$ limit)
iffalse: $[x]]$.
$\uparrow$ AbstractGenerator new ;
firstBlock: [ counter $\leftarrow 0$.
testBlock value: self first ]
nextBlock: [ testBlock value: self next ]
Show how to implement a method for the message from:to; that can be used to extract any contiguous set of values from the underlying generator, specified in terms of indices. Extend this to return any set of values for which the indices form an arithmetic progression.