"repeat for each" in reverse order ?

Robert Brenstein rjb at robelko.com
Tue Jun 28 06:53:31 EDT 2005


>On Jun 27, 2005, at 1:57 AM, Robert Brenstein wrote:
>
>>   repeat for each element x in y descending
>
>Now, is that with keys in descending order or elements in descending order?
>
>Dar

Sorry, Dar, I used element in the loose sense and really meant chunk 
types: char, word, item, line.

When it comes to the 'each element' form, you are right that it is 
ambiguous at first glance, but would seem reasonable that sorting 
applies to the elements themselves since keys are not explicitly 
entering the picture. To get sorting on keys we would need to say

   repeat for each line tKey in the keys of myArray ascending

While we can do sorting explicitly with the sort command, I like the 
idea of having ascending and descending options as a new feature. It 
would combine two steps into a single engine process without a need 
to shuffle sorted results back and forth between engine and our 
program.

Probably, to make it more complete, we would need to include numeric 
and international as options similarly as the sort itself has them.

Now, this has, of course, drifted away from the original request. For 
that one, the syntax could be something like

   repeat for each foo in foofoo down

No sorting involved, simple reversal of direction. Down is the 
closest of the existing keywords for me and already used in another 
form of repeat. And the other poster convinced me that even though it 
would be slower then forwards, it would still likely has enough speed 
benefit.

Robert

PS If this needs to be discussed further, may be we should move it to 
the improve-list. If anyone is filing it in bugzilla, let us know the 
number.



More information about the use-livecode mailing list