13 ms·
1. Change . to | 2. Reverse Now you have: words | map read | sum Or.. $ cat words | map -e read | sum
by worksonmymach 2y ago
1. Change . to |
2. Reverse
Now you have:
words | map read | sum
Or..
$ cat words | map -e read | sum
- tromp 2y agoWould you propose the same change for nested function calls y = f(g(h(x))), changing it into y = x | h | g | f ?
- worksonmymach 2y agoIt can look nice. It is like asking: passive or active voice? It depends what you are writing and what makes sense to the reader. I do like pipelines though!
- bhargav 2y agoYes but the notation of dot, plus such function names plus optional parens makes it sure read like English. That’s great but it’ll be a nightmare when you are also dealing with strings which similar English in it.
- kreyenborgi 2y ago|> is a common way of writing the pipe in haskell, so words |> map read |> sum IHP uses it a lot.