You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Inspired by Perl's -n and -p flags, supposing we had one or two flags that ran an implicit loop over all lines of stdin and called the given code as a function on each line? I'm thinking something like this:
T (a:q) == ()
P {
; Your code here
} V (g PE a)
corresponding to perl -p and the same thing without the P for perl -n.
It loops over all lines of stdin and runs your code against each one.
The final expression in your code is autoprinted. You can specify whatever list format you like via command-line argument.
Inside your code, the line of stdin is a; the actual command-line arguments are still accessible as b through e and also @>g.
Global variables retain their values from one iteration to the next (unless you don't want them to, in which case you can lead with WG).
Your code can call itself recursively using f.
One question: what actual flags do we use, since -n and -p (and -P) are already taken--as are -e (for Each) and -l (for Line)?
The text was updated successfully, but these errors were encountered:
Given the philosophy change in #42, flags should not be used for this purpose. But I think we could still implement the behavior using a character added to the beginning or end of the program.
Inspired by Perl's -n and -p flags, supposing we had one or two flags that ran an implicit loop over all lines of stdin and called the given code as a function on each line? I'm thinking something like this:
corresponding to
perl -p
and the same thing without theP
forperl -n
.a
; the actual command-line arguments are still accessible asb
throughe
and also@>g
.WG
).f
.One question: what actual flags do we use, since -n and -p (and -P) are already taken--as are -e (for Each) and -l (for Line)?
The text was updated successfully, but these errors were encountered: