Re: repeat with i=

2011-07-15 Thread James Hurley
-- Message: 7 Date: Thu, 14 Jul 2011 10:06:01 -0500 From: Ronald Zellner zell...@tamu.edu To: use-livecode@lists.runrev.com Subject: Re: repeat with i= Message-ID: f324e51b-41d7-4882-a0c8-7ee09c9f6...@tamu.edu Content-Type: text/plain; charset=us-ascii

Re: repeat with i=

2011-07-15 Thread Timothy Miller
Thanks for all the suggestions. I think I'll go with: on mouseUp local theNums put 1,2,3,4,5,6 into theNums sort items of theNums numeric by random(100) repeat with i = 1 to 6 do whatever item i of theNums end repeat end mouseUp This is probably erroneous but possibly

Re: repeat with i=

2011-07-15 Thread Pete
think I'll go with: on mouseUp local theNums put 1,2,3,4,5,6 into theNums sort items of theNums numeric by random(100) repeat with i = 1 to 6 do whatever item i of theNums end repeat end mouseUp This is probably erroneous but possibly the right general idea

Re: repeat with i=

2011-07-15 Thread Roger Eller
On Fri, Jul 15, 2011 at 6:56 PM, Pete wrote: Sounds like the best solution. Thanks for posting the question - I learned about delete, any, and more about sort! Pete Molly's Revenge http://www.mollysrevenge.com These little challenges are great for the LC community. I learn something every

Re: repeat with i=

2011-07-15 Thread J. Landman Gay
On 7/15/11 6:02 PM, Roger Eller wrote: On Fri, Jul 15, 2011 at 6:56 PM, Pete wrote: Sounds like the best solution. Thanks for posting the question - I learned about delete, any, and more about sort! Pete Molly's Revengehttp://www.mollysrevenge.com These little challenges are great for the

Re: repeat with i=

2011-07-14 Thread Scott Morrow
Cool, I didn't know about any. Thanks, Jacque! Scott Morrow On Jul 13, 2011, at 9:58 PM, J. Landman Gay wrote: On 7/13/11 11:33 PM, Pete wrote: You're right, should probably be something like replace y comma with empty in x. Plain old delete does it. Also, not everyone knows about

Re: repeat with i=

2011-07-14 Thread Keith Clarke
...so for a random selection, enforcing the use of all 6 items, would this work? put 1,2,3,4,5,6 into x repeat until x is empty put any item of x into y do something delete item y from x end repeat Best, Keith.. On 14 Jul 2011, at 05:58, J. Landman Gay wrote: On

Re: repeat with i=

2011-07-14 Thread Jim Ault
On Jul 14, 2011, at 12:05 AM, Keith Clarke wrote: ...so for a random selection, enforcing the use of all 6 items, would this work? put 1,2,3,4,5,6 into x repeat until x is empty put any item of x into y do something delete item y from x end repeat No, since the

Re: repeat with i=

2011-07-14 Thread Keith Clarke
, theNumbers)) from theNumbers end repeat I realise that this may not be the most efficient layout (one more line than yours!) but it reads nicely and could help in educational settings when teaching the application of scripts to formulae that use finite n-based series - I'm thinking here about

Re: repeat with i=

2011-07-14 Thread paolo mazza
Tha's interesting. I think you have to use delete.. of instead delete from . To me this is correct. put 1,2,3,4,5,6 into theNumbers repeat until theNumbers is empty put any item theNumbers into n put n after theNumberList delete item (itemOffset(n, theNumbers)) of

Re: repeat with i=

2011-07-14 Thread Jim Ault
into n do something delete (itemOffset(n, theNumbers)) from theNumbers end repeat I realise that this may not be the most efficient layout (one more line than yours!) but it reads nicely and could help in educational settings when teaching the application of scripts to formulae

Re: repeat with i=

2011-07-14 Thread Ronald Zellner
Jim's seems to be the most efficient and accurate, but I needed this change to make it work. ' of ' changed to 'in' I like to add something to create quick feedback- like the field chosen. Easier to see the result. Then switch to the complete function when the code is working. on mouseUp

Re: repeat with i=

2011-07-14 Thread Keith Clarke
Ronald, Sorry, don't use my first attempt - it had an error. You'd need the updated version that used itemoffset to delete the the specific number in the list, rather than it's position. To see what was used in each loop in real time, you can either put y or answer y To see the choices made

Re: repeat with i=

2011-07-14 Thread Klaus on-rev
Hi Ron, Am 14.07.2011 um 17:06 schrieb Ronald Zellner: Jim's seems to be the most efficient and accurate, but I needed this change to make it work. ' of ' changed to 'in' I like to add something to create quick feedback- like the field chosen. Easier to see the result. Then switch to the

Re: repeat with i=

2011-07-14 Thread J. Landman Gay
On 7/14/11 10:06 AM, Ronald Zellner wrote: Jim's seems to be the most efficient and accurate, I agree. Sorting the list before the loop and then peeling off the items one by one is the most efficient way to do it. I mentioned any because it's such a nice addition to the language, but I

Re: repeat with i=

2011-07-14 Thread James Hurley
I haven't been following this thread so my apologies if I'm missing the point, but a while back I had to deal with the task of selecting m random people for a voter pole from a list N registered voters, where N was over 100,000. Check out Random pick in Rev Online. I found using an array 3

Re: repeat with i=

2011-07-14 Thread Jerry J
On Jul 14, 2011, at 2:12 AM, Keith Clarke wrote: ...ah yes, of course, thanks Jim - I forgot that 'delete item y' is not the same as 'delete item *called* y' ! So, would itemoffset help...? put 1,2,3,4,5,6 into theNumbers repeat until theNumbers is empty put any item theNumbers

Re: repeat with i=

2011-07-14 Thread Pete
Doesn't setting the wholematches to true deal with this? Pete Molly's Revenge http://www.mollysrevenge.com On Thu, Jul 14, 2011 at 3:35 PM, Jerry J j...@jhj.com wrote: On Jul 14, 2011, at 2:12 AM, Keith Clarke wrote: ...ah yes, of course, thanks Jim - I forgot that 'delete item y' is not

Re: repeat with i=

2011-07-14 Thread Jerry J
Aha! The docs say so! Learned something new today. Thanks Pete, Jerry On Jul 14, 2011, at 3:51 PM, Pete wrote: Doesn't setting the wholematches to true deal with this? Pete Molly's Revenge http://www.mollysrevenge.com On Thu, Jul 14, 2011 at 3:35 PM, Jerry J j...@jhj.com wrote:

Re: repeat with i=

2011-07-14 Thread Pete
No problem. I'd definitely try it though - I've been bitten before by the docs saying things that weren't quite true! Pete Molly's Revenge http://www.mollysrevenge.com On Thu, Jul 14, 2011 at 3:58 PM, Jerry J j...@jhj.com wrote: Aha! The docs say so! Learned something new today. Thanks

Re: repeat with i=

2011-07-14 Thread Jerry J
Works in the message box. On Jul 14, 2011, at 4:11 PM, Pete wrote: No problem. I'd definitely try it though - I've been bitten before by the docs saying things that weren't quite true! Pete Molly's Revenge http://www.mollysrevenge.com On Thu, Jul 14, 2011 at 3:58 PM, Jerry J

repeat with i=

2011-07-13 Thread Timothy Miller
Hi, Let's say that I want to do something like repeat with i = 1 to 6 do whatever i end repeat Except, I want 1 to 6 to be in random sequence I could think of a few kludgy ways to do this. Is there a standard approach? A simple approach? Thanks in advance. Tim

Re: repeat with i=

2011-07-13 Thread Roger Eller
On Wed, Jul 13, 2011 at 9:01 PM, Timothy Miller wrote: Hi, Let's say that I want to do something like repeat with i = 1 to 6 do whatever i end repeat Except, I want 1 to 6 to be in random sequence I could think of a few kludgy ways to do this. Is there a standard approach? A simple

Re: repeat with i=

2011-07-13 Thread Pete
Maybe (untested): put 1,2,3,4,5,6 into x repeat with i=1 to 6 put item random(the number of items in x) into y do whatever with y put empty into item y of x end repeat Pete Molly's Revenge http://www.mollysrevenge.com On Wed, Jul 13, 2011 at 6:01 PM, Timothy Miller gand

Re: repeat with i=

2011-07-13 Thread Jerry J
On Jul 13, 2011, at 6:01 PM, Timothy Miller wrote: Hi, Let's say that I want to do something like repeat with i = 1 to 6 do whatever i end repeat Except, I want 1 to 6 to be in random sequence I could think of a few kludgy ways to do this. Is there a standard approach

Re: repeat with i=

2011-07-13 Thread Roger Eller
This one guarantees that each of the 6 random numbers is only used once. put 1,2,3,4,5,6 into x replace comma with cr in x repeat until (the number of lines of t) = 6 -- be cautious with until loops put random(6) into tLine if tLine is not among the lines of t then put (line

Re: repeat with i=

2011-07-13 Thread Nonsanity
...@mollysrevenge.com wrote: Maybe (untested): put 1,2,3,4,5,6 into x repeat with i=1 to 6 put item random(the number of items in x) into y do whatever with y put empty into item y of x end repeat Pete Molly's Revenge http://www.mollysrevenge.com On Wed, Jul 13, 2011 at 6:01 PM, Timothy

Re: repeat with i=

2011-07-13 Thread Dick Kriesel
On Jul 13, 2011, at 7:53 PM, Nonsanity wrote: I like Pete's best - closest to what I was thinking - I like Jerry's best - it's better than I was thinking ... Jerry's is less code executed less often: one statement once versus two statements for each item. -- Dick

Re: repeat with i=

2011-07-13 Thread Pete
to delete item y of x. I think the put empty would just put into that item, but the item would still be there, like: 1,2,,4,5,6 ~ Chris Innanen ~ Nonsanity On Wed, Jul 13, 2011 at 9:25 PM, Pete p...@mollysrevenge.com wrote: Maybe (untested): put 1,2,3,4,5,6 into x repeat with i=1

Re: repeat with i=

2011-07-13 Thread J. Landman Gay
On 7/13/11 11:33 PM, Pete wrote: You're right, should probably be something like replace y comma with empty in x. Plain old delete does it. Also, not everyone knows about the any keyword but it's really handy for lines like this: put item random(the number of items in x) of x into y

Re: repeat with i=

2011-07-13 Thread Pete
Great, learned two things form this - delete and any! Pete Molly's Revenge http://www.mollysrevenge.com On Wed, Jul 13, 2011 at 9:58 PM, J. Landman Gay jac...@hyperactivesw.comwrote: On 7/13/11 11:33 PM, Pete wrote: You're right, should probably be something like replace y comma with