Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Clojure has -> specifically to facilitate writing pipeline code that doesn't read backwards.


Or, in this case, ->>:

  (def lols (->> strs
                 (filter #(re-find #"LOL" %))
                 (map upper-case)
                 sort))
How I read it: take strs, filter the strings that contain "LOL", turn them into upper case and then sort them. Basically it reads the same as the pipeline example in the README.


Right – though for this example, `->>` (http://grimoire.arrdem.com/1.6.0/clojure.core/DASH__GT__GT/) works better than `->`. I created a GitHub issue to tell the creator about it: https://github.com/xiaq/elvish/issues/17.


(Also see my reply to thinkpad20.) I'm not sure about Haskell, but Clojure's -> is still a serial construct (functions invoked one after another), but pipeline is parallel.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: