Alice Community  

Go Back   Alice Community > Alice 2 > How do I...?

Reply
 
Thread Tools Display Modes
Explain the logic behind...
Old
fallout87
Junior Member
 
Status: Offline
Posts: 11
Join Date: Oct 2011
Location: Small Country Town
Default Explain the logic behind... - 10-07-2011, 08:35 AM

Could someone please explain the logic behind this:

While count.variable <= value.variable
count.variable set value to (count.variable +1)
(blahblahblah) method

Count.variable is set to 1 btw.
   
Reply With Quote
Old
TauTrumpsPi
Senior Member
 
TauTrumpsPi's Avatar
 
Status: Offline
Posts: 399
Join Date: Mar 2011
Location: The diamond layer
Default 10-07-2011, 08:03 PM

That is called a count controlled while loop. Basically, it is a loop statement

It will execute the method the value of the value.variable times

So, look at it like this

Counter = 1
Flag = 3

While Counter <= Flag
count.variable set value to (Counter + 1)
(blahblahblah) method


So, the (blah) method will execute until the counter exceeds the Flag, in which it will stop. This is usually only useful in languages that don't have loop statements


--------------------------------------------------------------------------------------------------------------------------
I have plenty of common sense. I just choose to ignore it.
-Calvin and Hobbes

Wondering about my Avatar?
http://en.wikipedia.org/wiki/Tardigrade

Wondering about my username?
http://www.youtube.com/watch?v=jG7vhMMXagQ
   
Reply With Quote
Old
fallout87
Junior Member
 
Status: Offline
Posts: 11
Join Date: Oct 2011
Location: Small Country Town
Default 10-13-2011, 02:10 PM

Quote:
Originally Posted by TauTrumpsPi View Post
That is called a count controlled while loop. Basically, it is a loop statement

It will execute the method the value of the value.variable times

So, look at it like this

Counter = 1
Flag = 3

While Counter <= Flag
count.variable set value to (Counter + 1)
(blahblahblah) method


So, the (blah) method will execute until the counter exceeds the Flag, in which it will stop. This is usually only useful in languages that don't have loop statements

Thanks for the info!

That helped a lot : )

They are useful when an assessment says no "for loops" as well. lol
   
Reply With Quote
Old
TauTrumpsPi
Senior Member
 
TauTrumpsPi's Avatar
 
Status: Offline
Posts: 399
Join Date: Mar 2011
Location: The diamond layer
Default 10-14-2011, 02:38 PM

Yeah, that too, "for loops" usually take less time, but this does have it's uses. What language are you using, C, maybe?


--------------------------------------------------------------------------------------------------------------------------
I have plenty of common sense. I just choose to ignore it.
-Calvin and Hobbes

Wondering about my Avatar?
http://en.wikipedia.org/wiki/Tardigrade

Wondering about my username?
http://www.youtube.com/watch?v=jG7vhMMXagQ
   
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump



Copyright ©2024, Carnegie Mellon University
Alice 2.x © 1999-2012, Alice 3.x © 2008-2012, Carnegie Mellon University. All rights reserved.