User talk:Chunes: Difference between revisions

Content added Content deleted
Line 32: Line 32:
\Calling the routine
\Calling the routine
Put 5 into a number. Factorialize the number.
Put 5 into a number. Factorialize the number.
Write "" then the number on the console.</lang> --[[User:Chunes|Chunes]] ([[User talk:Chunes|talk]]) 15:48, 25 September 2020 (UTC)
Write "" then the number on the console.</lang>
:Regarding the input stuff, I would refactor it slightly so you don't need any global state.

:<lang plainenglish>To run:
::Regarding the input stuff, I would refactor it slightly so you don't need any global state.
::<lang plainenglish>To run:
Start up.
Start up.
Demonstrate input.
Demonstrate input.
Line 52: Line 51:
Repeat.</lang>
Repeat.</lang>


::The idea is putting the loop entirely inside the <code>To demonstrate input:</code> routine so that you don't need any global flags. Notice how this can be done concisely with <code>Repeat</code>. I also used <code>Repeat</code> when a negative number is encountered to act like a <code>continue</code> does in most other languages. --[[User:Chunes|Chunes]] ([[User talk:Chunes|talk]]) 17:03, 25 September 2020 (UTC)
:The idea is putting the loop entirely inside the <code>To demonstrate input:</code> routine so that you don't need any global flags. This can be done concisely with <code>Repeat.</code> by itself at the end of the routine. The loop will begin again from the top of the routine. I also used <code>repeat</code> when a negative number is encountered to act like a <code>continue</code> does in most other languages. --[[User:Chunes|Chunes]] ([[User talk:Chunes|talk]]) 17:03, 25 September 2020 (UTC)