# irregular iteration

4 messages
Open this post in threaded view
|

## irregular iteration

 somehow this got mis-threaded. this is a new thread. 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
Open this post in threaded view
|

## Re: irregular iteration

 Hi, how about a simple loop: steps := #(2 3 4 5) readStream. init := sum := 1. last := 100. [sum > 100 | steps atEnd] whileFalse:                 [sum := sum + steps next.                 Transcript                         show: sum printString;                         cr] Best, Steffen Am .10.2014, 02:17 Uhr, schrieb Adam Crumpton <[hidden email]>: > somehow this got mis-threaded. this is a new thread. > > 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