Efficiency question for list modification
Alex Tweedly
alex at tweedly.net
Sat Mar 12 07:42:43 EST 2011
"newer", but not "new" :-)
'split by column' and 'split by row' appeared somewhere around 3.5 (I think)
-- Alex.
On 12/03/2011 01:11, Bob Sneidar wrote:
> Wha?? There is a newer form of split and combine??
>
> Bob
>
>
> On Mar 11, 2011, at 4:42 PM, Alex Tweedly wrote:
>
>>> FlexibleLearning wrote:
>>>
>>>> This is BAD...
>>>> repeat for each line L in tData
>>>> add 1 to n
>>>> put (item 1 of L/div1) into item 1 of line n of stdout
>>>> put (item 2 of L/div2) into item 2 of line n of stdout
>>>> end repeat
>>>>
>> The use of "put ... after ..." is so efficient this may be an interesting but insignificant aside.
>>
>> But ... it occurs to me there is another approach to this problem.
>>
>> 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.
>>
>>
>> _______________________________________________
>> 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
>
> _______________________________________________
> 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