Hacker News new | ask | show | jobs
by techno_modus 2851 days ago
I personally think first about the loop/iterator organization (FROM in SQL) and only after that what I am going to do with its elements.

However,

    SELECT a1,a2,... FROM Table AS t WHERE Condition
is syntactically equivalent to Python list comprehension:

    [(t.a1,t.a2,...) for t in Table if Condition]
Here the use of attributes (SELECT) is also written before the iterator.

SELECT is also analogous to normal loops:

    foreach t in Table
      if not Condition: continue
      # Use t.a1, t.a2 etc.
Here we first provide the loop specification while the usage of elements is written only in the body.