--
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
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
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
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
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
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
...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
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
, 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
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
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
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
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
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
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
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
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
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
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:
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
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
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
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
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
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
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
...@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
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
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
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
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
31 matches
Mail list logo