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
The |> operator (inspired from F# / Ocaml) would have the left hand side's stdout split into lines, and feed each line from left into a newly spawned process into the right.
echo"A \n B \n C"|>echo
would result into 3 echo processes, each receiving the parameter A, B, and C individually, resulting into the output:
A
B
C
That can then be chained into multiple, like in this example:
get_numbers |> times_two |> plus_one |>echo
where get_numbers prints N numbers (one per line), and times_two gets invoked N times and multiplies each number by 2, and plus_one gets invoked N times and adds 1 over the intermediate result, to then have each result printed, once per line.
notes
this is similar to what xargs -n1 does, but this syntactic shougar would not need to spawn the process xargs and have it more platform independant (e.g. xargs would not exist on Windows).
The syntax could make the code look more readable / maintainable as well.
The text was updated successfully, but these errors were encountered:
The
|>
operator (inspired from F# / Ocaml) would have the left hand side's stdout split into lines, and feed each line from left into a newly spawned process into the right.would result into 3
echo
processes, each receiving the parameter A, B, and C individually, resulting into the output:That can then be chained into multiple, like in this example:
where
get_numbers
prints N numbers (one per line), andtimes_two
gets invoked N times and multiplies each number by 2, andplus_one
gets invoked N times and adds 1 over the intermediate result, to then have each result printed, once per line.notes
this is similar to what
xargs -n1
does, but this syntactic shougar would not need to spawn the processxargs
and have it more platform independant (e.g. xargs would not exist on Windows).The syntax could make the code look more readable / maintainable as well.
The text was updated successfully, but these errors were encountered: