Reverse a list
gcanyon at gmail.com
Tue Feb 10 04:58:10 CET 2015
It seems that what we've lost with unicode/7 is the speed of character
references. In other words, this:
On Sun, Feb 8, 2015 at 4:37 PM, Alex Tweedly <alex at tweedly.net> wrote:
> SO, instead, we can use "put ... into char x to y of ..." - since it uses
> char indexing, it takes constant time (i.e. no scan, just directly replace
> the chars.
... no longer applies. I ran a simple test to completely reverse a string,
not line by line, but character by character, something like: repeat with i
= length(string) down to 1; put char i of string after result; end repeat
and it was orders of magnitude slower even than Alex's line-by-line
solution. I subbed byte for char, and it doesn't seem to matter or change
anything. Until that issue is addressed, it seems any solution that depends
on repeated character or byte indexes into a string is going to suffer from
the highway line painter's problem: he paints fewer lines each day as he
gets farther and farther away from the paint bucket.
On Mon, Feb 9, 2015 at 8:27 PM, J. Landman Gay <jacque at hyperactivesw.com>
> On 2/9/2015 8:10 PM, Kay C Lan wrote:
>> On Tue, Feb 10, 2015 at 8:53 AM, Mike Kerner<MikeKerner at roadrunner.com>
>> >can we come up with a dataset for this test?
>> I personally find scripting a standard dataset the easiest.
> I just used the colorNames repeated a number of times, since they start
> out alphabetized and you can see what you're doing. But I didn't come
> anywhere near thousands of lines, just a few repeats so I could eyeball it.
> Since I was only looking at relative speeds, the actual timing wasn't too
> important to me.
> Jacqueline Landman Gay | jacque at hyperactivesw.com
> HyperActive Software | http://www.hyperactivesw.com
> use-livecode mailing list
> use-livecode at lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your
> subscription preferences:
More information about the use-livecode