From: Virgil on
In article
<e20363bd-932f-4886-ab96-bbf492196cd4(a)e35g2000yqm.googlegroups.com>,
PremiumBlend <mnhollinger(a)yahoo.com> wrote:

> 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.

Glad to have been of use.
From: John H Meyers on
On 5/2/2010 10:16 PM:

> I have a list with six elements and I wish to get
> elements one, three, and five

"And now for something completely different"

@ Extract only the odd-numbered elements of any list
\<< 1 \<< NSUB 2 MOD NOT { DROP } IFT \>> DOSUBS \>>

http://en.wikipedia.org/wiki/Monty_Python's_Flying_Circus
http://en.wikipedia.org/wiki/And_Now_for_Something_Completely_Different

[r->] [OFF]
From: PremiumBlend on
On May 7, 2:05 pm, John H Meyers <jhmey...(a)nomail.invalid> wrote:
> On 5/2/2010 10:16 PM:
>
> > I have a list with six elements and I wish to get
> > elements one, three, and five
>
> "And now for something completely different"
>
> @ Extract only the odd-numbered elements of any list
> \<< 1 \<< NSUB 2 MOD NOT { DROP } IFT \>> DOSUBS \>>
>
> http://en.wikipedia.org/wiki/Monty_Python's_Flying_Circushttp://en.wikipedia.org/wiki/And_Now_for_Something_Completely_Different
>
> [r->] [OFF]

Also:

@ Extract only the even-numbered elements of any list
\<< 1 \<< NSUB 2 MOD { DROP } IFT \>> DOSUBS \>>

I like it!