Hi Adam,
>>to: limit byNext: streamOrCollection do: a1block
| each rs |
each := self.
rs := streamOrCollection readStream.
[ each <= limit
] whileTrue:
[ a1block value: each.
rs atEnd ifTrue: [rs reset].
each := each + rs next
]
You'll also need this one (which is missing in most st implementations)
ReadStream>>readStream
^self
and possibly this one
>>reset
position := 0
(Is this for school? Be sure and check the results!)
Yours,
-cstb
On 10/13/2014 4:12 PM, Adam Crumpton wrote:
> hi!
>
> instead of:
>
> 1 to: 100 by: 2 do: [:n | n doSomething ].
>
> I want to iterate over the numbers in an irregular way based on some
> sort of list or stream, like:
>
> 1 to: 100 byNext: #(1 2 3 4 5) do: [:n | Transcript show: (n
> printString), cr].
>
> and have it show:
>
> 1
> 3
> 6
> 10
> 15
> 16
> 18
> 21
> 24
> 29
> ...
>
> any suggestions on implentation would be appreciated. The list has to
> be of arbitrary length.
>
> thanks
> Adam Crumpton
> _______________________________________________
> vwnc mailing list
>
[hidden email]
>
http://lists.cs.uiuc.edu/mailman/listinfo/vwnc>
>
_______________________________________________
vwnc mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/vwnc