ela
Contents

ManualAgents

A list from a loop

In the terminalela --spec a-list-from-a-loop

Where Python writes a comprehension, [f for f in files if is_big(f)], or another language a filter and a map, ela writes the loop on one line after =; when keeps the items:

big   = for f in $files when file.info($f)["size"] > 1_000_000; $fnames = for r in $rows when has($r, "name"); $r["name"]dirty = for d in $repos when not git -C $d diff --quiet; $d

One expression after the ;, and always a list, [] when nothing is kept. No brackets around it, no if and no :. For lines of work in each round, call a proc: infos = for f in $files; describe($f). In an ordinary loop, when picks the rounds the body runs: for f in $files when is_big($f); rm $f. (ela --spec for-value)