
-----------------------------------
gothic-sorceress
Tue Sep 30, 2008 11:57 am

Increasing Loop
-----------------------------------
I need to make a loop that increases by a number that is increasing, if that makes any sense?

-----------------------------------
Insectoid
Tue Sep 30, 2008 1:02 pm

RE:Increasing Loop
-----------------------------------
Make a loop that adds 1 to a number, then add that number to another number.


x += 1
y += x


-----------------------------------
Clayton
Tue Sep 30, 2008 1:28 pm

RE:Increasing Loop
-----------------------------------
I think what you are looking for is a for loop. Check out the [Turing Walkthrough] (still auto-linked?) for awesome tutorials to get you started :)

-----------------------------------
Zeroth
Tue Sep 30, 2008 11:56 pm

Re: Increasing Loop
-----------------------------------
I think you are looking for a while loop actually. I use these in python:


i=o
while i!=guard_condition:
    if blah:
        i+=2
    elif blah

The idea is that you can modify i or the guard_condition inside the loop to continue for as long as you need to.

-----------------------------------
SNIPERDUDE
Wed Oct 01, 2008 6:58 am

RE:Increasing Loop
-----------------------------------
No, in Turing you would use a for loop.

for i : 1 .. number
    %put whatever code in here
end for

-----------------------------------
andrew.
Wed Oct 01, 2008 1:05 pm

RE:Increasing Loop
-----------------------------------
There are no while loops in Turing. The closest thing really is a for loop.

Like SNIPERDUDE said, use:
for i : 1 .. number 
    %put whatever code in here 
end for

By using this code, you are starting at 1 and counting up to whatever "number" happens to be.

-----------------------------------
[Gandalf]
Wed Oct 01, 2008 1:21 pm

Re: RE:Increasing Loop
-----------------------------------
There are no while loops in Turing. The closest thing really is a for loop.
Uhm.  There's loop, which is a heck of a lot closer to a while loop than a for loop, seeing as the for loop is...  a for loop.

Turing's "while loop":
loop 
    exit when 
end loop

-----------------------------------
Tony
Wed Oct 01, 2008 1:21 pm

RE:Increasing Loop
-----------------------------------
a while loop in Turing is

loop
   exit when condition
   ...
end loop


a do while loop simply moves the exit condition to the bottom of the loop


loop
   ...
   exit when condition
end loop


-----------------------------------
Insectoid
Wed Oct 01, 2008 7:06 pm

RE:Increasing Loop
-----------------------------------
The point is, the easiest way (IMO) is to use a for loop.

-----------------------------------
OneOffDriveByPoster
Wed Oct 01, 2008 8:43 pm

Re: Increasing Loop
-----------------------------------
I need to make a loop that increases by a number that is increasing, if that makes any sense?Sounds like nested for-loops.  But you really should explain more.

-----------------------------------
gothic-sorceress
Thu Oct 02, 2008 10:34 am

Re: Increasing Loop
-----------------------------------
To explain further, I need to make a loop that first outputs 1, then 3, then 6, then 10, then 15, then 21, so the amount the loop increases by is increased by one for each repeat.  Does that help at all?

-----------------------------------
Insectoid
Thu Oct 02, 2008 11:45 am

RE:Increasing Loop
-----------------------------------
Seeing as this is going nowhere, I'll just post a simple example of one of the many ways you can do this.


Answer removed.


-----------------------------------
Warchamp7
Thu Oct 02, 2008 12:04 pm

Re: Increasing Loop
-----------------------------------
To explain further, I need to make a loop that first outputs 1, then 3, then 6, then 10, then 15, then 21, so the amount the loop increases by is increased by one for each repeat.  Does that help at all?

I believe this is what you are looking for

var answerRemoved : string

-----------------------------------
Insectoid
Thu Oct 02, 2008 1:10 pm

RE:Increasing Loop
-----------------------------------
Oh, come on, I had the same answer! You didn't even raise your hand! Warchamp, pshaw, more like warchump! :P

Whatever, as long as he gets it.

-----------------------------------
Clayton
Thu Oct 02, 2008 1:30 pm

RE:Increasing Loop
-----------------------------------
Just giving him the code to do it is not helping him whatsoever. Giving him hints on how to solve the problem is a much better idea.

Mull the following code over, run it, then think it over again:

for i : 1 .. 10
    put i
end for
