Efficiency question for list modification

FlexibleLearning admin at FlexibleLearning.com
Sat Mar 12 04:17:08 EST 2011


Summary:
We are trying to divide pairs of comma-delimted items in a return-delimited
list by two different numbers.

>Use "split by column" to separate the two columns
>Then use "split by row" to convert the columns into arrays
>Then use  "divide <array> by <value>" to do the maths
>Then combine them back again.
>
>It's not (quite) as efficient for my simple test data as the other way,
>but I think it's an interesting way to use the newer form of the split
>command.
>
> on newway  @t, pCol1Divisor, pCol2Divisor
>    set the columnDelimiter to ","
>    set the rowDelimiter to CR
>    split t  by column
>    split t[1]  by row
>    divide t[1] by pCol1Divisor
>    combine t[1] by row
>    split t[2] by row
>    divide t[2] by pCol2Divisor
>    combine t[2] by row
>    combine t by column
> end newway
>
>-- Alex.

Unfortunately 'combine' does not retain the original order. It should, but
it doesn't. The sort order for array elements seems to be alpha and not
numeric, even though the keys are numeric. This means that the output list
is not in the same order as the input list.

Hugh Senior
FLCo





More information about the use-livecode mailing list