How to use an array to solve the following...

Glen Bojsza gbojsza at gmail.com
Sun Feb 19 13:53:56 EST 2012


Having limited experience with arrays I thought this might be a good
question to ask the group.

Is the use of arrays to solve this appropriate? Efficient? Fast?

If the answers are yes then it will help with the bigger problem that I am
trying to address but for now I am looking for advice or help on how to do
this using arrays... just a note the size that the solution would need to
work on would involve a couple of hundred thousand rows.

I have the following text field example with data....

Pacer
xs        wt
10        4
20        7
40      22
60      71
120    99
200    12

I need to be able to ensure that between wt values that there is no more
than 10 between xs values (this includes before and after a wt value). If
there is then a new xs value must be added with a wt value of 0

This is what the solution should look like (ignoring the <-- added
comments).

Pacer
xs        wt
10        4
20        7
30        0     <---added because of wt =7 at 20 so a xs 0 value is added
after
40      22
50        0     <---added because of wt =22 at 40 so a xs 0 value is added
after  ***but this then solves the problem of wt 71 at 60??!!
60      71
70        0     <---added because of wt =71 at 60 so a xs 0 value is added
after
110      0     <---added because of wt =99 at 120 so a xs 0 value is added
before
120    99
130      0     <---added because of wt =99 at 120 so a xs 0 value is added
after
190      0     <---added because of wt =12 at 200 so a xs 0 value is added
before
200    12

I look forward to comments and suggestions.

regards,

Glen



More information about the use-livecode mailing list