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

dunbarx at aol.com dunbarx at aol.com
Sun Feb 19 18:20:25 EST 2012


Glen.


I sort of get what you are trying to do, and yes, arrays will be the most compact way to do it, though regular variables can work as well.


But what happens if you already have the "xs" values in conecutive "by 10" order? Are you allowed to bump later values by 10? In other words, are you required to insert values at certain places in the list? Does this matter? I don't see the rationale behind where you inserted new values in your example. Or in yet other words, why can't new data be appended to the list, incremented by 10 in the "xs" portion? This is something I need to know to even start thinking about a method.


Craig Newman



-----Original Message-----
From: Glen Bojsza <gbojsza at gmail.com>
To: How to use LiveCode <use-livecode at lists.runrev.com>
Sent: Sun, Feb 19, 2012 1:56 pm
Subject: How to use an array to solve the following...


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
_______________________________________________
use-livecode mailing list
use-livecode at lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode

 




More information about the use-livecode mailing list