top | item 45975842

(no title)

kiratp | 3 months ago

A for loop has a conditional in it.

Unless by conditionals we mean “no if/else” and not “no branch instructions”.

discuss

order

WhyNotHugo|3 months ago

The conditional here only makes it stop when it reaches 100. The solution can be adapted to use a while loop if you’re okay with it running indefinitely.

kiratp|3 months ago

A loop either never halts or has a conditional. I guess a compiler could elide a “while True:” to a branch-less jump instruction.

One hack would be to use recursion and let stack exhaustion stop you.