Math challenge thing

J. Landman Gay jacque at hyperactivesw.com
Sun Jul 30 14:25:04 EDT 2006


Thierry Arbellot wrote:
> On 2006, Jul 30, , at 20:03, J. Landman Gay wrote:
> 
>> I had to write a loop the other day that cycled around a list of 4 
>> numbers. Usually when I need to do that, I like to use the following, 
>> where x is the current number that I want to increase:
>>
>>   put (x mod 4)+1 into x
>>
>> This goes around and around, giving a value of x between 1 and 4. But 
>> this time I needed to include zero. I need a series "0,1,2,3". No 
>> matter how I tinkered, I couldn't get a zero out of it.
>>
>> I wrote it the long way: if x = 3 then put 0 into x
>>
>> But I got curious. Is there a way to do it the cool way? I'm a math 
>> idiot so maybe it's easy.
> 
> put (x+1) mod 4 into x

Geez. Now I feel really dumb. You didn't even have to think about that, 
did you? :)

Thanks.

-- 
Jacqueline Landman Gay         |     jacque at hyperactivesw.com
HyperActive Software           |     http://www.hyperactivesw.com



More information about the use-livecode mailing list