[Tutor] comparing seqs by successive intervals

kevin parks kp8 at mac.com
Sun Jan 18 00:37:37 EST 2004


hi all.

I am trying to take some lists and compares them by measuring the 
intervals or gaps between each successive list item. I should also 
point out that everything here is modulo 12), so if we have a list like 
so:

seq01 = [5, 7, 8, 11]

the interval from list item 0 (5) to list item 1(7) is 2, item 1(7) to 
item 2 (8) is 1, and item 2 (8) to the last (11) is 3.

seq02 = [1, 3, 4, 7]

by this criteria seq02 would be the same as the intervals between each 
successive sequence item is the same:

2-1-3

so it would be great if it indicated whether they were the same or not 
and if so printed out the interval sequence.

Yet i am not quite sure how best to do this. Do i do parallel 
traversals with something like for (x, y) in foo ...? or do i first 
measure the intervals in one list and then the other? What if i have 
more than 2 lists? is that too hairy to deal with? How can i do this 
with lists of different lengths and have it at least compare the 
sequences as far as the shortest list?

hmm.... So many question for such a small brain such as i have. I have 
had a need to do similar things before. I am hoping some one can give 
me a push in the right direction or talk me through the steps. I would 
love to see how something like this would be done. It may seem odd, but 
is something i keep coming across and am not yet able to get my head 
'round.

Help... Anyone...?

cheers,

kevin





More information about the Tutor mailing list