http://calcg.org/newlogo2.png Not Logged in.
Login | Register

General Discussion Board \ Game and Program Discussion \ Repeat And While, The Differences

Click here to log in (you must be logged in to post comments).

AuthorComment
IdealIdeas
Marine
Posted: 18 Dec 2008
19:54 GMT
Total Posts: 35
This Is For Programmers Who Wish To Know Exactly Why WHILE Is Different From REPEAT.

How While Works Is That So Long The While Condition Is TRUE It Keeps Executing Whats Between The While And End.

How Repeat Works Is That So Long The Repeat Condition Is FALSE It Keeps Executing Whats Between Repeat And End.

To Show You What I Mean Here Is An Example Showing You How Both While And Repeat Can Achieve The Function. If You Look You Will See The Difference Besides 1 Being While And The Other Being Repeat.
Example:
WHILE COMMAND
:20 -> A
:While A>1
:A-1 -> A
:End
:While A=1
:Text(0,0,"A=0")
:0 -> A
:End

REPEAT COMMAND
:20 -> A
:Repeat A<2
:A-1 -> A
:Enf
:Repeat A≠1
:Text(0,0,"A=0")
:0 -> A
:End

I Hope Ya Can See The Difference
I Hope This Helps Anyone Who Does Programming And Cannot Tell The Difference Between Repeat And While.
Now Even Though They Vary Slightly It Doesnt Mean You Cant Use Only 1 Of The 2 And Completely Screw The Other.
Zachary940
Wraith
avatar
Posted: 18 Dec 2008
23:01 GMT
Total Posts: 714
I hope you understand the benefits of using one over the other, and when Repeat should be used rather then While.



---
It is much easier to suggest solutions when you know nothing about the problem.
haveacalc
Guardian
avatar
Posted: 19 Dec 2008
09:57 GMT
Total Posts: 1111



---
-quoted directly from most movies that don't exist (and some that do).
Xphoenix
Ultralisk
avatar
Posted: 19 Dec 2008
19:52 GMT
Total Posts: 210
Also, I think a Repeat loop always executes at least once (checks condition after running code), as opposed to a While loop, which checks the condition and then runs the code.

---
~Xphoenix
Vectris
Ultralisk
avatar
Posted: 20 Dec 2008
07:40 GMT
Total Posts: 375
Yes, the most important part of each command wasn't shown in here.

While is what's known as a pre-test loop. It will check for if the condition is true before running. Repeat is a post-test loop, it checks the condition after running at least once. So While can run 0 or more times, Repeat will always run at least once.
me2
Goliath
avatar
Posted: 23 Dec 2008
07:44 GMT
Total Posts: 171
A while loop uses less RAM (1 less letter in the command).Anyway, the pre-test ability is quite useful, so I recommend using While most of the time.

---
<--- Going out with a bang.
IdealIdeas
Marine
Posted: 23 Dec 2008
16:52 GMT
Total Posts: 35
To haveacalc
I Capitalize The First Letter Of Every Word Just For A Few Reasons.
1. My Pinky And Finger Next To Pinky Always Lay On The Shift.
2. I Think It Looks Better When Every Word Is Capitalized.
3. Its A Way To Rebel Against The Ways Of How Writing Should Be Written.
4. I Don't Believe That No Single Word Should Be More Important Than Any Other.
5. Its A Habit That I Don't Wish To Break.
6. It Just Feels Right To Capitalize Every Word In The Sentence, Just Like How Some People Feel Its Right To Write The As Teh.
And This Should Explain Why I Capitalize Or Try To Capitalize Every Word.
And There May Be A Few More Reasons That I Do So, Just That I'm Not Conciously Aware Of.
Zachary940
Wraith
avatar
Posted: 24 Dec 2008
17:55 GMT
Total Posts: 714
Reasons not to capitalize every word:
1. I don’t care where your pinky is, stop making excuses.
2. It really is just annoying and hard to read.
3. This is not the 70’s so therefore there is no need to rebel.
4. Try to argue that with your English professor. You will lose.
5. All good things must end.
6. Just because it feels right, doesn’t mean that it is. Example: “Hi I’m a killer and it just feels so right to kill people. I get all fuzzy and warm inside when I do.”


---
It is much easier to suggest solutions when you know nothing about the problem.
Vectris
Ultralisk
avatar
Posted: 24 Dec 2008
18:17 GMT
Total Posts: 375
I love #6, and for 5, who said it was a good thing to begin with 0.o

I agree II, you should really stop, you can type a lot faster once you get used to NOT doing it. Really, please work on that.





Portal | My Account | Register | Lost Password or Username | TOS | Disclaimer | Help | Site Search | File Archives Copyright © 2002-2019 CalcG.org