How to use an array to solve the following...

Pete pete at mollysrevenge.com
Mon Feb 20 21:54:11 EST 2012


Interesting, and it kinda makes sense.  For elements, there's no
positioning required like with lines/words/item, just a case of cycling
through the keys - which is what "repeat for each line <x> in the keys of
<array> does I suppose.
Pete

On Mon, Feb 20, 2012 at 6:20 PM, Geoff Canyon Rev <gcanyon+rev at gmail.com>wrote:

> Certainly correct, but there is not the tremendous performance advantage to
> using "for each element in..." For items, lines, and words, using
> "item/line/word of myContainer" gets worse the larger the container is. For
> character and with arrays, it doesn't. In my quick testing here, there's
> just about no performance advantage to doing repeat for each element.
> There's about a 4x benefit for using "repeat for each char" over "repeat
> with i = 1 to length(myString)" But note that it seems to be 4x regardless
> of the string length. That isn't the case with items, lines, and words --
> there, the longer your container, the more you'll suffer.
>
>
> On Mon, Feb 20, 2012 at 3:02 PM, Bob Sneidar <bobs at twft.com> wrote:
>
> > Also each element in <array>
> >
> > Bob
> >
> >
> > On Feb 20, 2012, at 10:34 AM, gcanyon+rev wrote:
> >
> > > any time you find yourself writing:
> > >
> > > repeat with i = 1 to the number of lines|words|items of someContainer
> > >
> > > stop. Rewrite it as:
> > >
> > > repeat for each line|word|item in someContainer
> >
> >
> > _______________________________________________
> > 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
>
>


-- 
Pete
Molly's Revenge <http://www.mollysrevenge.com>



More information about the use-livecode mailing list