3 ms·
But each successive 'command' is a method on what's constructed so far; not an entirely different command to which we delegate processing of what we have so far
by OJFord 8y ago
But each successive 'command' is a method on what's constructed so far; not an entirely different command to which we delegate processing of what we have so far.
The Python:
length(','.join(map(lambda n: n+1, range(1, 4)))
is a bit closer, but the order's now reversed, and then jumbled by the map/lambda. (Though I suppose arguably awk does that too.)
- duckerude 8y agoThat's true. It's far from being generally applicable. But it might be the most "mainstream" pipe-like processing notation around. Nim has an interesting synthesis where a.f(b) is only another way to spell f(a, b), which (I think) matches the usual behavior of |> while still allowing familiar-looking method-style syntax. These are equivalent: [1, 2, 3].map(proc (n: int): int = n + 1).map(proc (n: int): string = $n).join(",").len len(join(map(map([1, 2, 3], proc (n: int): int = n + 1), proc (n: int): string = $n), ",")) The difference is purely cosmetic, but readability matters. It's easier to read from left to right than to have to jump around.
- ticklemyelmo 8y agoC# extension methods provide the same syntax, and it is used for all of its LINQ pipeline methods. It's amazing how effective syntactic sugar can be for readability.