Computer Science Canada

turing - help w outputting numbers on 1 line

Author:  comp_help [ Sat Apr 11, 2009 9:09 pm ]
Post subject:  turing - help w outputting numbers on 1 line

Ok, I would like to output this code on 1 line, and it has to be using loops. Should I make ten variables to store all the numbers then output them all in the end? or Is there any other way? Confused

Turing:

var count: int:= 10

loop
put count
exit when count = 0
count:= count - 1
end loop

Author:  Dusk Eagle [ Sat Apr 11, 2009 9:15 pm ]
Post subject:  Re: turing - help w outputting numbers on 1 line

Just put a .. after your "put foo" statement. That's all you have to do!

Author:  saltpro15 [ Sat Apr 11, 2009 9:18 pm ]
Post subject:  RE:turing - help w outputting numbers on 1 line

you need this
Turing:

var count: int:= 10

loop
put count ..
exit when count = 0
count:= count - 1
end loop


note I added a .. after put count, to keep Turing on the current line

Author:  comp_help [ Sat Apr 11, 2009 9:19 pm ]
Post subject:  RE:turing - help w outputting numbers on 1 line

Wow! that was nice but I need to put space, actually tab, in between the numbers, How do I do this? Thanks

Author:  comp_help [ Sat Apr 11, 2009 9:22 pm ]
Post subject:  Re: turing - help w outputting numbers on 1 line

Nvm, I got it Smile

var count: int:= 10

loop
put count, "\t"..
exit when count = 0
count:= count - 1
end loop

So, Thank you very much Saltpro15 and Dusk Eagle.

One last thing, what is ".." function called? Is it in turing reference?

Author:  Zren [ Sun Apr 12, 2009 12:12 am ]
Post subject:  Re: turing - help w outputting numbers on 1 line

Oh wow. The Turing reference actually refers to it as dot-dot. That's it.


Quote:
put:
This put statement is sometimes used to close off a line that has been output piece by piece using put with dot-dot.

&&

locate:
put "*" .. % Use dot-dot to avoid clearing end of line


: