Re: Reversing a list

2008-04-23 Thread J. Landman Gay

Sarah Reichelt wrote:

On Fri, Apr 4, 2008 at 10:14 AM, Sarah Reichelt
[EMAIL PROTECTED] wrote:

And the winner is...

 Jacque (with one modification).

 local tCount

 function reverseList pList
put the number of lines in pList into tCount
sort lines of pList by mySort()
return pList
 end reverseList

 function mySort
subtract 1 from tCount
return tCount
 end mySort


OK, this realised this working for me and I finally figured out what
was going on - the sort needs to be numeric!
So change the sort line to this:

 sort lines of pList numeric by mySort()


Oops. Good catch. :)

--
Jacqueline Landman Gay | [EMAIL PROTECTED]
HyperActive Software   | http://www.hyperactivesw.com
___
use-revolution mailing list
use-revolution@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-revolution


Re: Reversing a list

2008-04-22 Thread Sarah Reichelt
On Fri, Apr 4, 2008 at 10:14 AM, Sarah Reichelt
[EMAIL PROTECTED] wrote:
 And the winner is...

  Jacque (with one modification).

  local tCount

  function reverseList pList
 put the number of lines in pList into tCount
 sort lines of pList by mySort()
 return pList
  end reverseList

  function mySort
 subtract 1 from tCount
 return tCount
  end mySort

OK, this realised this working for me and I finally figured out what
was going on - the sort needs to be numeric!
So change the sort line to this:

 sort lines of pList numeric by mySort()

Cheers,
Sarah
___
use-revolution mailing list
use-revolution@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-revolution


Re: Reversing a list

2008-04-04 Thread BNig

to Jaque and Sarah

just one more modification:

numeric


if you do the reverse sort the way it on eleven lines the word one to eleven
on each then it returns:

eleven
ten
one
nine
eight
seven
six
five
four
three
two

if you add numeric it works correctly like in:


function reverseList pList
put the number of lines in pList into tCount
sort lines of pList numeric by mySort()
return pList
end reverseList

then it returns

eleven
ten
nine
eight
seven
six
five
four
three
two
one

So whatever the inner working of this algorithm without numeric it does not
sort numerically on the number passed

So for me without numeric it returns the wrong sort order if using more than
ten lines. This could be possibly very confusing to detect.

fwiw

bernd



Sarah Reichelt-2 wrote:
 
 And the winner is...
 
 Jacque (with one modification).
 
 local tCount
 
 function reverseList pList
 put the number of lines in pList into tCount
 sort lines of pList by mySort()
 return pList
 end reverseList
 
 function mySort
 subtract 1 from tCount
 return tCount
 end mySort
 
 I had thought that Jacque's must be faster than Jan's because Jan's
 does more operations per cycle, but it was a bit slower. Then I
 noticed that Jacque had used sort lines of pList by mySort(each)
 where Jan had left out the each. Deleting the each from Jacque's
 function made it the fastest. Fractionally faster than Jan's, it takes
 about 2/3 of the time of Mark's solution using arrays, and it way
 faster than the string method.
 
 Thanks everyone - fun and instructive :-)
 
 Cheers,
 Sarah
 ___
 use-revolution mailing list
 use-revolution@lists.runrev.com
 Please visit this url to subscribe, unsubscribe and manage your
 subscription preferences:
 http://lists.runrev.com/mailman/listinfo/use-revolution
 
 

-- 
View this message in context: 
http://www.nabble.com/Reversing-a-list-tp16466585p16489681.html
Sent from the Revolution - User mailing list archive at Nabble.com.

___
use-revolution mailing list
use-revolution@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-revolution


Re: Reversing a list

2008-04-04 Thread Sarah Reichelt
  HOWEVER, what naive types like me would like to know
  are:

  1. How did you time these routines ?

I built a test list of 5000 lines, then stored the millisecs, ran the
reversing routine and checked the difference between the current
millisecs and the stored millisecs.


  2. Although it is very clever (I, for one, had a bit
  of fun having a try) to write a routine that reverses
  a list a few demi-semi-gulps faster than another,
  until we are all using super computers to find out the
  question for 42 (pace Douglas Adams) I wonder why
  those few micro-gulps really might matter ?

My original routine took almost 2 seconds to reverse a list of about
5000 lines on a fast computer. While not too critical, this was enough
to make the program feel unresponsive. Even if I had decided to accept
this, what if in the future, my list had grown to 20,000 lines. Then I
would be looking at a delay of 8 seconds after a click. While
computers keep getting faster, you have to allow for data getting
larger too.

Cheers,
Sarah
___
use-revolution mailing list
use-revolution@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-revolution


Re: Reversing a list

2008-04-04 Thread Mark Schonewille

Hi Sarah,

Did you also check what happens with the speed when the amount of  
data increases? I wonder whether arrays get faster or slower relative  
to repeat loops, when you multiple the amount of data by 10 several  
times.


Best,

Mark

--

Economy-x-Talk
Consultancy and Software Engineering
http://economy-x-talk.com
http://www.salery.biz

Get your store on-line within minutes with Salery Web Store software.  
Download at http://www.salery.biz


Op 4-apr-2008, om 13:52 heeft Sarah Reichelt het volgende geschreven:


I built a test list of 5000 lines, then stored the millisecs, ran the
reversing routine and checked the difference between the current
millisecs and the stored millisecs.

snip

___
use-revolution mailing list
use-revolution@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-revolution


Re: Reversing a list

2008-04-04 Thread Eric Chatonet

Hi Richmond,

When a program is unresponsive, animated gifs are stopped.

Le 4 avr. 08 à 14:30, Richmond Mathewson a écrit :

Sarah Reichelt wrote:

this was enough to make the program feel
unresponsive

and all along I thought the answer was to show the
end-users an inane animated GIF image while the
processing happens :)


Best regards from Paris,
Eric Chatonet.

Plugins and tutorials for Revolution: http://www.sosmartsoftware.com/
Email: [EMAIL PROTECTED]/



___
use-revolution mailing list
use-revolution@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-revolution


Re: Reversing a list

2008-04-04 Thread BNig

hi Mark
if you fill up a field with like a button script like this:

on mouseUp pMouseBtnNo
put A,B,C,D into trandomChar
set the numberformat to #
put 0 into tCounter
repeat 9
add 1 to tCounter
put any item of trandomChar  tCountera longer text to see
the difference between short and longn text on the time it takes to reverse
the order of a field  return after tCollector
end repeat
delete last char of tCollector
put tCollector into field 1
end mouseUp

it creates a line of text in my view representative of an average line of
text:

D 1 a longer text to see the difference between short and longn text on
the time it takes to reverse the order of a field 


and if you compare

arrays 

like 
(Mark Schonewille)
--
on mouseUp pMouseBtnNo
put the millisec into tStart
put field 1 into temp
put reverseList(temp) into temp2
put temp2 into field 1
put the millisec - tStart
end mouseUp


private function reverseList theListArray
split theListArray by cr
combine theListArray by cr and tab
sort lines of theListArray numeric descending by item 1 of each
split theListArray by column
return theListArray[2]
end reverseList
--
it takes for 100.000 time 1800 millisecs on a macBook Pro 2.33

for an adapted Jaques/Jan solution (same field with 100.000 lines, same
computer):
---
local tCount
on mouseUp
put the millisec into tStart
put the number of lines of field 1 into tCount
sort field 1 numeric by mySort()
put the millisec - tStart
end mouseUp

private function mySort
subtract 1 from tCount
return tCount
end mySort
---

it takes about 850 millisecs

1800 millisecs versus 850 is a huge amount of time for the user (a lot of
gulps, by the way: what is the standard gulp anyway?, I know how to
transform the Percentage of the maximum velocity of sheep in a vacuum:
http://www.theregister.co.uk/Design/page/reg-standards-converter.html#velocity
, but you would have to submit the gulb as a distinct and defined unit of
time :-

Allright, I added private to the function which is only availabel to rev
= 2.8.1.
it saves about 50 milliseconds.

So the solution proposed by Jaque and Jan is definitely faster and, provided
you add numeric, just as correct.

regards

Bernd





Richmond Mathewson wrote:
 
 Sarah Reichelt wrote:
 
 And the winner is...
 
 and  jolly well done to Jacque!
 
 HOWEVER, what naive types like me would like to know
 are:
 
 1. How did you time these routines ?
 
 For the sake of argument, I hardly had time to take a
 gulp of coffee before mine was done: presumably you
 don't do timings in gulps, semi-gulps, demi-semi-gulps
 and so on.
 
 2. Although it is very clever (I, for one, had a bit
 of fun having a try) to write a routine that reverses
 a list a few demi-semi-gulps faster than another,
 until we are all using super computers to find out the
 question for 42 (pace Douglas Adams) I wonder why
 those few micro-gulps really might matter ?
 
 sincerely, Richmond Mathewson
 
 
 
 A Thorn in the flesh is better than a failed Systems Development Life
 Cycle.
 
 
 
   __
 Sent from Yahoo! Mail.
 A Smarter Inbox http://uk.docs.yahoo.com/nowyoucan.html
 ___
 use-revolution mailing list
 use-revolution@lists.runrev.com
 Please visit this url to subscribe, unsubscribe and manage your
 subscription preferences:
 http://lists.runrev.com/mailman/listinfo/use-revolution
 
 

-- 
View this message in context: 
http://www.nabble.com/Reversing-a-list-tp16494644p16505535.html
Sent from the Revolution - User mailing list archive at Nabble.com.

___
use-revolution mailing list
use-revolution@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-revolution


Re: Reversing a list

2008-04-03 Thread Mark Schonewille

Hi Sarah,

After a little discussion in ChatRev, this is what I end up with:

function reverseList theListArray
  split theListArray by cr
  put the keys of theListArray
  combine theListArray by cr and tab
  sort lines of theListArray numeric descending by item 1 of each
  split theListArray by column
  return theListArray[2]
end reverseList

Best regards,

Mark Schonewille

--

Economy-x-Talk Consulting and Software Engineering
http://economy-x-talk.com
http://www.salery.biz

A large collection of scripts for HyperCard, Revolution, SuperCard and  
other programming languages can be found at http://runrev.info





On 3 apr 2008, at 06:00, Sarah Reichelt wrote:

OK people, what's the fastest way to reverse the order of lines in a
list. I have a list of images gathered together by filtering matching
files from a set of folders. Now I want to be able to reverse the
order, but their file names are varied and so I have no obvious way to
sort them.

I realise I could just use a repeat for each loop and put each one
before a new list variable, but that seems rather clumsy, and using
before slows down when I have thousands of records.

I'm hoping that Jacque will chime in with one of her custom sort ideas
that I never can think of, but anyone is welcome to come up with some
elegant solution.

Cheers,
Sarah
___
use-revolution mailing list
use-revolution@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your  
subscription preferences:

http://lists.runrev.com/mailman/listinfo/use-revolution


___
use-revolution mailing list
use-revolution@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-revolution


Re: Reversing a list

2008-04-03 Thread BNig

hi,

 -- Jan Schenkels solution:
##
local sLineCount, sCurrentLine

on mouseUp
put 0 into sCurrentLine
put the number of lines in field 1 into sLineCount
put the millisec into tStart
sort field 1 by ReverseOrder()
put the millisec - tStart
end mouseUp

function ReverseOrder
add 1 to sCurrentLine
return sLineCount - sCurrentLine
end ReverseOrder
##

I tried this on field with 10 lines filled with number from 1 to 10, it
works and is fast.

I then tried it with a field filled with 10 line filled with numbers
1 to 9

then it does not work correctly. Since I dont even understand the syntax in
the first place I have no idea why.

on the 10 lines once the last lines are:

00020
90001
00019
00018
00017
00016
00015
00014
00013
00012
00011
00010
9
9
8
7
6
5
4
3
2
1

While Mark Schonewilles solution:

on mouseUp pMouseBtnNo
put the millisec into tStart
put field 1 into temp
put reverseList(temp) into temp2
put temp2 into field 1
put the millisec - tStart
end mouseUp

function reverseList theListArray
split theListArray by cr
--   put the keys of theListArray
combine theListArray by cr and tab
sort lines of theListArray numeric descending by item 1 of each
split theListArray by column
return theListArray[2]
end reverseList
--

on the same list in the field works for small and large number of lines and
repeatedly and  still is very fast (580 msec) on a MacBook Pro 2.33

I didnt try where the cutoff for correct results in Jans function is.
 I thought just to mention the problem because it might not be so obvious
for lists that are not easily checked for consistency

and thanks for these functions, I always enjoy the discussions on the list

regards

Bernd

-- 
View this message in context: 
http://www.nabble.com/Reversing-a-list-tp16466585p16467477.html
Sent from the Revolution - User mailing list archive at Nabble.com.

___
use-revolution mailing list
use-revolution@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-revolution


Re: Reversing a list

2008-04-03 Thread wayne durden
Hi Bernd,

I suspect the issue in the large list is that it is taking more than a
second to populate the sort list or the start time is near the rollover of
milliSecond ...

Wayne


On Thu, Apr 3, 2008 at 9:21 AM, BNig [EMAIL PROTECTED] wrote:


 hi,

  -- Jan Schenkels solution:
 ##
 local sLineCount, sCurrentLine

 on mouseUp
put 0 into sCurrentLine
 put the number of lines in field 1 into sLineCount
put the millisec into tStart
 sort field 1 by ReverseOrder()
 put the millisec - tStart
 end mouseUp

 function ReverseOrder
add 1 to sCurrentLine
return sLineCount - sCurrentLine
 end ReverseOrder
 ##

 I tried this on field with 10 lines filled with number from 1 to 10, it
 works and is fast.

 I then tried it with a field filled with 10 line filled with numbers
 1 to 9

 then it does not work correctly. Since I dont even understand the syntax
 in
 the first place I have no idea why.

 on the 10 lines once the last lines are:

 00020
 90001
 00019
 00018
 00017
 00016
 00015
 00014
 00013
 00012
 00011
 00010
 9
 9
 8
 7
 6
 5
 4
 3
 2
 1

 While Mark Schonewilles solution:

 on mouseUp pMouseBtnNo
put the millisec into tStart
put field 1 into temp
put reverseList(temp) into temp2
put temp2 into field 1
put the millisec - tStart
 end mouseUp

 function reverseList theListArray
split theListArray by cr
--   put the keys of theListArray
combine theListArray by cr and tab
sort lines of theListArray numeric descending by item 1 of each
split theListArray by column
return theListArray[2]
 end reverseList
 --

 on the same list in the field works for small and large number of lines
 and
 repeatedly and  still is very fast (580 msec) on a MacBook Pro 2.33

 I didnt try where the cutoff for correct results in Jans function is.
  I thought just to mention the problem because it might not be so obvious
 for lists that are not easily checked for consistency

 and thanks for these functions, I always enjoy the discussions on the list

 regards

 Bernd

 --
 View this message in context:
 http://www.nabble.com/Reversing-a-list-tp16466585p16467477.html
 Sent from the Revolution - User mailing list archive at Nabble.com.

 ___
 use-revolution mailing list
 use-revolution@lists.runrev.com
 Please visit this url to subscribe, unsubscribe and manage your
 subscription preferences:
 http://lists.runrev.com/mailman/listinfo/use-revolution

___
use-revolution mailing list
use-revolution@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-revolution


Re: Reversing a list

2008-04-03 Thread Eric Chatonet

Hi Richmond,

Le 3 avr. 08 à 17:28, Richmond Mathewson a écrit :

Stupid Me! realise that the line:

put the number of lines of fld fZ into TNUM

is redundant and only serves to slow the thing down.

Clumsy or not (!!):

on mouseUp
  put the number of lines of fld fZ + 1 into ANUM
  repeat for each line ZNUM in fld fZ
put (ANUM -1) into ANUM
put ZNUM into line ANUM of fld fA
  end repeat
end mouseUp

does things bl**dy quickly, and without the need of
some fancy homemade function!


If you want to speed up this by about one hundred:

  put fld fZ into tList
  put the number of lines of tList + 1 into ANUM
  repeat for each line ZNUM in tList
put (ANUM -1) into ANUM
put ZNUM into line ANUM of tReverseList
  end repeat
  put tReverseList into fld fA

Best regards from Paris,
Eric Chatonet.

Plugins and tutorials for Revolution: http://www.sosmartsoftware.com/
Email: [EMAIL PROTECTED]/



___
use-revolution mailing list
use-revolution@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-revolution


Re: Reversing a list

2008-04-03 Thread J. Landman Gay

BNig wrote:


I tried this on field with 10 lines filled with number from 1 to 10, it
works and is fast.

I then tried it with a field filled with 10 line filled with numbers
1 to 9

then it does not work correctly. Since I dont even understand the syntax in
the first place I have no idea why.


Because you have substituted numbers for alpha characters, you'll need 
to sort numeric. Then it seems to work. Eric's solution is similar to 
mine, so I tested mine, and adding numeric fixed it.


--
Jacqueline Landman Gay | [EMAIL PROTECTED]
HyperActive Software   | http://www.hyperactivesw.com
___
use-revolution mailing list
use-revolution@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-revolution


Re: Reversing a list

2008-04-03 Thread Sarah Reichelt
And the winner is...

Jacque (with one modification).

local tCount

function reverseList pList
put the number of lines in pList into tCount
sort lines of pList by mySort()
return pList
end reverseList

function mySort
subtract 1 from tCount
return tCount
end mySort

I had thought that Jacque's must be faster than Jan's because Jan's
does more operations per cycle, but it was a bit slower. Then I
noticed that Jacque had used sort lines of pList by mySort(each)
where Jan had left out the each. Deleting the each from Jacque's
function made it the fastest. Fractionally faster than Jan's, it takes
about 2/3 of the time of Mark's solution using arrays, and it way
faster than the string method.

Thanks everyone - fun and instructive :-)

Cheers,
Sarah
___
use-revolution mailing list
use-revolution@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-revolution


Re: Reversing a list

2008-04-02 Thread John Tregea
Dear sarah,
I think you can use something like;
sort lines of fld my_list by word 2 of each
or
sort lines of fld my_list descending by word 3 of each
Regards
John

___
use-revolution mailing list
use-revolution@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-revolution


Re: Reversing a list

2008-04-02 Thread Sarah Reichelt
On Thu, Apr 3, 2008 at 2:11 PM, John Tregea [EMAIL PROTECTED] wrote:
 Dear sarah,
  I think you can use something like;
  sort lines of fld my_list by word 2 of each
  or
  sort lines of fld my_list descending by word 3 of each
  Regards
  John


Thanks John, but they are a collection of filenames gathered from
sub-folders, so each folder's items are already sorted and the order
of the folders is logical. I have no single work or item I can use for
a sort, so I really just have to reverse the order of the lines.

Sarah
___
use-revolution mailing list
use-revolution@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-revolution


Re: Reversing a list

2008-04-02 Thread John Tregea
Gotcha I think...

Maybe

repeat with x = (the number of lines of fld file_list) down to 1
 put line x of fld file_list and return after tNewList
end repeat
delete the last line of tNewList
put tNewList into fld file_list

HTH

John

 Thanks John, but they are a collection of filenames gathered from
 sub-folders, so each folder's items are already sorted and the order
 of the folders is logical. I have no single work or item I can use for
 a sort, so I really just have to reverse the order of the lines.

Sarah
___
use-revolution mailing list
use-revolution@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-revolution

___
use-revolution mailing list
use-revolution@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-revolution


Re: Reversing a list

2008-04-02 Thread Jan Schenkel
--- Sarah Reichelt [EMAIL PROTECTED] wrote:
 OK people, what's the fastest way to reverse the
 order of lines in a
 list. I have a list of images gathered together by
 filtering matching
 files from a set of folders. Now I want to be able
 to reverse the
 order, but their file names are varied and so I have
 no obvious way to
 sort them.
 
 I realise I could just use a repeat for each loop
 and put each one
 before a new list variable, but that seems rather
 clumsy, and using
 before slows down when I have thousands of
 records.
 
 I'm hoping that Jacque will chime in with one of her
 custom sort ideas
 that I never can think of, but anyone is welcome to
 come up with some
 elegant solution.
 
 Cheers,
 Sarah
 

Hi Sarah,

Beating Jacque to it with this:

##
local sLineCount, sCurrentLine

on mouseUp
  put 0 into sCurrentLine
  put the number of lines in field 1 into sLineCount
  sort field 1 by ReverseOrder()
end mouseUp

function ReverseOrder
  add 1 to sCurrentLine
  return sLineCount - sCurrentLine
end ReverseOrder
##

How fast it is for huge datasets, I'm not sure; but it
works a treat :-)

Hope this helped,

Jan Schenkel.

Quartam Reports  PDF Library for Revolution
http://www.quartam.com

=
As we grow older, we grow both wiser and more foolish at the same time.  (La 
Rochefoucauld)


  

You rock. That's why Blockbuster's offering you one month of Blockbuster Total 
Access, No Cost.  
http://tc.deals.yahoo.com/tc/blockbuster/text5.com
___
use-revolution mailing list
use-revolution@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-revolution


Re: Reversing a list

2008-04-02 Thread J. Landman Gay

Sarah Reichelt wrote:

OK people, what's the fastest way to reverse the order of lines in a
list. I have a list of images gathered together by filtering matching
files from a set of folders. Now I want to be able to reverse the
order, but their file names are varied and so I have no obvious way to
sort them.

I realise I could just use a repeat for each loop and put each one
before a new list variable, but that seems rather clumsy, and using
before slows down when I have thousands of records.

I'm hoping that Jacque will chime in with one of her custom sort ideas
that I never can think of, but anyone is welcome to come up with some
elegant solution.


Does this work:

local tCount

on mouseUp
  put fld 1 into tData
  put the number of lines in tData into tCount
  sort lines of tData by mySort(each)
  put tData into fld results
end mouseUp

function mySort
   subtract 1 from tCount
   return tCount
end mySort

Funny you should mention this, because just today I was working on a 
handler for this same concept for RevLive.


--
Jacqueline Landman Gay | [EMAIL PROTECTED]
HyperActive Software   | http://www.hyperactivesw.com
___
use-revolution mailing list
use-revolution@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-revolution