> IMO it would be clearer, and equally elegant, to write > this as something like > > for i in indices(myList): > ... > > which is easily accomplished with the aid of a suitable > definition for indices(). No language changes needed. I think that for i in myList.keys(): would be even better, because it allow the same usage for dict and list. Of course that wouldn't generalize to other sequences that support len. Incidentally, I've always liked Algol 68's loop syntax, which if I remember right is something like this: [ for <id> ] [ from <expr> ] [ to <expr> ] [ by <expr> ] [ while <expr> ] do <suite> od So one would write for i to n do ... od or even for i from 0 while <whatever> do ... od which would loop while <whatever> is true and keep count of the iterations.
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