Though it's mostly a matter of taste, I find pipelines simpler and more natural than method calls. Compare:
xs.filter(p).map(f)
with filter p xs | map f
(Suppose filter and map are implemented such that they accept input either on the command line or from pipeline.)Well, lets try Haskell syntax
map f $ filter p xs
what, don't like the reverse order? That's fixable.
If we define # as reverse function application, it's xs # filter p # map f
or filter p xs # map f
which is quite similar to what you are looking for.
Here's a comparison of code to do the same thing written in Ruby:
That's 60 characters versus 39 (most of these are just because the "commands" are longer – and I don't think anyone would even try to argue that 'cat' or 'wc' is more readable than 'File.readlines' or 'length').I ran them on Python 2.7's library directory and my version counted four lines more – I didn't investigate, but I think yours missed lines when cating files without trailing newline. I'd argue that's a bug in your code :)