# Efficiency question for list modification

dunbarx at aol.com dunbarx at aol.com
Thu Mar 10 14:18:17 EST 2011

```I ran this with a field "rawData" containing 5000 lines:

on mouseUp
put  the ticks into aa
put  fld "rawdata" into temp
put 3 into div1
put 5 into div2
repeat with y = 1 to the number of lines of temp
put item 1 of line y of temp / div1 & "," & item 2 of line y of temp / div2 into line y of temp
end repeat
put temp into fld "tresult"
put the ticks - aa
end mouseUp

Took about 2.5 seconds.

If that is too slow, what if you added a third item for each of the lines in your data field, such that the lines were numbered:

If you had:

3,6
4,7
5,8

Make it into:

1,3,6
2,4,7
3,5,8

Now you can use an array, and the ordering can be recovered since the lines contain unique identifiers.

Craig Newman

-----Original Message-----
From: FlexibleLearning <admin at FlexibleLearning.com>
To: use-livecode at lists.runrev.com
Sent: Thu, Mar 10, 2011 1:51 pm
Subject: Efficiency question for list modification

Problem:
I have a long list of several thousand lines.
Each line contains two comma-separated numbers.
I want to divide the first item of each line by one divisor, and divide the
second item of each line by a different divisor.
The list order must stay the same.

Example:
Using 2 and 5 as divisors...
10,10
12,15
8,12
would become
5,2
6,3
4,2.4

Options:
Using "repeat with n=1 to num of lines" takes far too long.
Using "repeat for each line L" either attempts to modify read-only data, or
is only 25% faster using a dumping variable.
Using split/combine will mess up the ordering (numeric array keys are not
sorted numerically with combine).

Any other ideas?

Hugh Senior
FLCo

_______________________________________________
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