Efficiency question for list modification

Bob Sneidar bobs at twft.com
Fri Mar 11 20:11:45 EST 2011


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





More information about the use-livecode mailing list