[Tutor] Alternating patterns

kevin parks kp8 at mac.com
Wed Mar 29 04:52:54 CEST 2006


I have a set that i iterate over... but each time through it i would 
like to alternate between the original set and a variation of the set 
that has one of the members of the set altered (by + or - 1)

So if my original set is:

[0, 2, 4, 5, 7, 9, 11]

I would use that the first pass but on the second pass i might like  
the third member (4,) to become 3, (-1) resulting in : [0, 2, 3, 5, 7, 
9, 11]

But then back again to the original  on the next pass (+1 back to 4,): 
[0, 2, 4, 5, 7, 9, 11]

and then back: [0, 2, 3, 5, 7, 9, 11] again, etc.

in other words i would like to alternate members of the set back and 
forth. Usually only 1 (or sometimes 2,) member at time. i could also 
imagine a needing(alter one, alter another, undo that, undo the first 
back to the original set):

[0, 2, 4, 5, 7, 9, 11] --> [0, 2, 3, 5, 7, 9, 11] --> [0, 2, 3, 5, 7, 
8, 10] --> [0, 2, 3, 5, 7, 9, 11] --> [0, 2, 4, 5, 7, 9, 11]

or:

original --> [0, 2, 4, 5, 7, 9, 11]
altered --> [0, 2, 3, 5, 7, 9, 11]
now back to 4, but change something else (like 11, is now 10):
[0, 2, 4, 5, 7, 9, 10]

etc...

How can one make such alternating patterns?

-kp--



More information about the Tutor mailing list