Hacker News new | ask | show | jobs
by jules 5770 days ago
This, in my opinion, is one of the greatest strengths that OOP has over FP: data.map(...).reduce(...). It doesn't really have anything to do with OOP, you could just as well have such a syntax for calling functions. In F# you do have the |> operator that does something like this.

This may seem superficial, but it helps readability a lot. The human mind (or mine at least) is just not well suited to unraveling nested structures.

2 comments

You can get a similar effect in Clojure with the "->" operator:

http://clojure.github.com/clojure/clojure.core-api.html#cloj...;

So you can take

    (foo (bar (baz "Hi!")))
and make it

    (-> "Hi!" baz bar foo)
Whoa! The UNIX shell's pipelines!
The odd thing is that the semantics of the Unix pipeline model is more similar to lazy sequences in Haskell or Clojure.

It is common to have one function generating a lazy sequence, another taking the output of that function and generating another lazy sequence, and so on until you get your final results out at the other end. The nice thing is that at no point in time is it necessary to have the entire sequence in memory.

A Unix pipeline is similar, in that one process consumes the output of another process as it becomes available, as opposed to having to wait for the first process to complete its task before the next process in the pipeline can start.

yep. and i suppose you won't be surprised to learn its called the pipeline operator.