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

Clojure has a threading macro built in (http://clojuredocs.org/clojure.core/-%3E) which lets you write code like :

    user=> (-> "a b c d" 
               .toUpperCase 
               (.replace "A" "X") 
               (.split " ") 
               first)
It is trivial to write the macro in other Lisps.


This is one of the nicest macros - chaining with sane return semantics and no overhead/boxing required. Breaks my heart trying to replicate it.




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

Search: