repeat with i=

Keith Clarke keith.clarke at clarkeandclarke.co.uk
Thu Jul 14 05:12:06 EDT 2011


...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 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 that use finite n-based series - I'm thinking here about permutations (nCr), combinations (nPr), binomials, factorials, statistical analysis, etc. Just a thought and hopefully not too much of a hijacking of the thread :-)
Best,
Keith..

On 14 Jul 2011, at 08:23, Jim Ault wrote:

> 
> 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 first pass could choose '2',
> then the next pass could choose '6'
> and produce the error "item 6 does not exist.
> 
> My preference would be to do the
> 
> put "1,2,3,4,5,6" into theNums
> sort  items of theNums numeric by random(1000000)
> repeat for each item Y of theNums
>      do "some command" & Y
> end repeat
> 
> 
> Jim Ault
> Las Vegas
> 
> 
> 
> _______________________________________________
> 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





More information about the use-livecode mailing list