Using Step with “For In” and modifying lists in the Ring programming language

Hello

We can use the step option with “for in” to skip items

Example

aList = 1:10
for x in aList Step 2
See x + nl
next

Also we can modify lists using “for in”

Example

aList = 1:3
see aList
for x in aList
switch x
on 1 x="one"
on 2 x ="two"
on 3 x = "three"
off
next
see aList

Output

1
2
3
one
two
three

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s