From: PremiumBlend on 2 May 2010 23:16 Hello, I have a list with six elements and I wish to get elements one, three, and five: \<< { 1 2 3 4 5 6 } \-> list \<< 1 5 START list 'loop-clause' 2 STEP \>> \>> I want to use the GET and INCR commands in the 'loop-clause' but how do I vary the increment by two? Mark
From: Virgil on 3 May 2010 01:03 In article <437da0f4-5ed8-47fd-baa6-27bb3d3d37f8(a)o8g2000yqo.googlegroups.com>, PremiumBlend <mnhollinger(a)yahoo.com> wrote: > Hello, > > I have a list with six elements and I wish to get > elements one, three, and five: > > \<< { 1 2 3 4 5 6 } \-> list > \<< 1 5 START list 'loop-clause' 2 STEP \>> > \>> > > I want to use the GET and INCR commands > in the 'loop-clause' but how do I vary the > increment by two? > > Mark \<< { 1 2 3 4 5 6 } \-> list \<< 1 5 FOR x list x GET 2 STEP \>> will leave 1,3 and 5 on the stack.
From: PremiumBlend on 3 May 2010 11:53 On May 3, 1:03 am, Virgil <Vir...(a)home.esc> wrote: > In article > <437da0f4-5ed8-47fd-baa6-27bb3d3d3...(a)o8g2000yqo.googlegroups.com>, > > PremiumBlend <mnhollin...(a)yahoo.com> wrote: > > Hello, > > > I have a list with six elements and I wish to get > > elements one, three, and five: > > > \<< { 1 2 3 4 5 6 } \-> list > > \<< 1 5 START list 'loop-clause' 2 STEP \>> > > \>> > > > I want to use the GET and INCR commands > > in the 'loop-clause' but how do I vary the > > increment by two? > > > Mark > > \<< { 1 2 3 4 5 6 } \-> list > \<< 1 5 FOR x list x GET 2 STEP \>> > will leave 1,3 and 5 on the stack. Thanks for the reply! So, the FOR loop index kept in local variable 'x' is initialized at one and uses the same varying increment as STEP, is that correct?
From: Virgil on 3 May 2010 16:39 In article <36e3f7ed-8ce9-41ff-80cb-6651f1ba7df7(a)q32g2000yqb.googlegroups.com>, PremiumBlend <mnhollinger(a)yahoo.com> wrote: > On May 3, 1:03�am, Virgil <Vir...(a)home.esc> wrote: > > In article > > <437da0f4-5ed8-47fd-baa6-27bb3d3d3...(a)o8g2000yqo.googlegroups.com>, > > > > �PremiumBlend <mnhollin...(a)yahoo.com> wrote: > > > Hello, > > > > > I have a list with six elements and I wish to get > > > elements one, three, and five: > > > > > \<< { 1 2 3 4 5 6 } \-> list > > > � �\<< 1 5 START list 'loop-clause' 2 STEP \>> > > > \>> > > > > > I want to use the GET and INCR commands > > > in the 'loop-clause' but how do I vary the > > > increment by two? > > > > > Mark > > > > \<< { 1 2 3 4 5 6 } \-> list > > � �\<< 1 5 FOR x list x GET �2 STEP \>> > > will leave 1,3 and 5 on the stack. > > Thanks for the reply! So, the FOR loop index > kept in local variable 'x' is initialized at one > and uses the same varying increment as > STEP, is that correct? Right! There are 4 versions of this loop structure possible, each prefaced by a pair of numbers, a starting value and an ending value. 'START ... NEXT' and 'START ... <step size> STEP' neither of which require a named loop variable and do not allow access to values of that variable and 'FOR <loop variable name> ... NEXT' and 'FOR <loop variable name> ...<step size> STEP' both require a name to be uses as a local variable within the loop (so it can be a name used elsewhere if that original usage need not be accessed inside the loop), and the current value of the loop variable can be accessed within each iteration by using its local name.
From: PremiumBlend on 3 May 2010 20:44
On May 3, 4:39 pm, Virgil <Vir...(a)home.esc> wrote: > In article > <36e3f7ed-8ce9-41ff-80cb-6651f1ba7...(a)q32g2000yqb.googlegroups.com>, > > > > > > PremiumBlend <mnhollin...(a)yahoo.com> wrote: > > On May 3, 1:03 am, Virgil <Vir...(a)home.esc> wrote: > > > In article > > > <437da0f4-5ed8-47fd-baa6-27bb3d3d3...(a)o8g2000yqo.googlegroups.com>, > > > > PremiumBlend <mnhollin...(a)yahoo.com> wrote: > > > > Hello, > > > > > I have a list with six elements and I wish to get > > > > elements one, three, and five: > > > > > \<< { 1 2 3 4 5 6 } \-> list > > > > \<< 1 5 START list 'loop-clause' 2 STEP \>> > > > > \>> > > > > > I want to use the GET and INCR commands > > > > in the 'loop-clause' but how do I vary the > > > > increment by two? > > > > > Mark > > > > \<< { 1 2 3 4 5 6 } \-> list > > > \<< 1 5 FOR x list x GET 2 STEP \>> > > > will leave 1,3 and 5 on the stack. > > > Thanks for the reply! So, the FOR loop index > > kept in local variable 'x' is initialized at one > > and uses the same varying increment as > > STEP, is that correct? > > Right! > > There are 4 versions of this loop structure possible, each prefaced by a > pair of numbers, a starting value and an ending value. > > 'START ... NEXT' > and > 'START ... <step size> STEP' > > neither of which require a named loop variable and do not allow access > to values of that variable > and > > 'FOR <loop variable name> ... NEXT' > and > 'FOR <loop variable name> ...<step size> STEP' > > both require a name to be uses as a local variable within the loop (so > it can be a name used elsewhere if that original usage need not be > accessed inside the loop), and the current value of the loop variable > can be accessed within each iteration by using its local name.- Hide quoted text - > > - Show quoted text - I'm crystal clear on this now. |