[Greg Wilson] > I would also like to volunteer to repeat the "simultaneous loop" syntax > experiment with list comprehensions, i.e. see whether what's being > proposed lines up with people's pre-existing intuitions. [Guido] > Please do! > > Though I have no doubt of the outcome: > > [x+y for x in [10, 20, 30] for y in [1, 2, 3]] > > will be almost universally understood to mean > > [11, 12, 13, 21, 22, 23, 31, 32, 33]. I'm not sure about that! Greg hangs out with functional programmers and old Fortran-heads. Fortran has a handy construct called "implied DO (loops)" in I/O statements, and in those the *innermost* (leftmost) shorthand loop varies fastest. So I expect the Fortran'ers to guess [11, 21, 31, 12, 22, ...] I agree the experiment is worth trying, but I'm not sure we're observing anything other than experienced programmers' prior language-dependent conditioning ... which would also explain why neither Greg's functional nor Fortran guinea pigs had any concept of lockstep iteration across multiple loop controls. BTW, an MxN slice of a 2D array A in Fortran will often show up in an I/O stmt as ... ((A(I,J), I=1,M), J=1,N) ... and the "innermost fastest" rule relates directly to Fortran's oddball decision to use column-major array storage: the natural way to write the I/O using implied DOs caters to varying the first index fastest (== contiguous memory locations under column-major storage). It's not like there's a *profound* reason behind this <wink>.
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