Dale Strickland-Clark wrote: > How about, for "execute at least once": > > REPEAT: > code > WHILE condition > > REPEAT: > code > UNTIL condition Has no one else found that the majority of while-type loops actually need some code before the test and some after? Doubly so in Python where it seems impossible to embed a local side effect in the while condition. As a result, most non-for loops degenerate into while 1: set up for this cycle if c: break whatever needs to be done Instead we keep getting suggestions for another loop structure that's comparable in lack of generality to "while", instead of taking a good look at how loops are formed in practice and generalizing the concept accordingly. If new syntax were to be added to the language, I'd rather see something like Dale's suggestion but removing the constraint that the UNTIL (or WHILE) statement has to be at the end - better yet, remove the constraint that there can be only one, thus making it a synonym for if...break. The existing while loop, and the repeat...until loop suggested above, are both special cases of the general loop. Cheers, Bob.
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4