comp creates a new function that you can store.
-> threads a value through a series of expressions.

On Wed, Apr 1, 2009 at 12:52 AM, kkw <kevin.k....@gmail.com> wrote:

>
> Hi folks,
>
>    I have some code where I wanted to:
> - take a list of stuff (which includes another list inside)
> - use 'seq-utils/flatten' to flatten the list
> - use 'interpose' to add comma-delimiting strings between the elements
> - print out the results, thereby creating comma-delimited output
>
>    I may choose between:
>
>              ((comp
>                  (fn [x] (apply println x))
>                  (fn [x] (interpose ", " x))
>                  seq-utils/flatten)
>                 mr)
>
> OR
>
>              (-> mr
>                seq-utils/flatten
>                ((fn [x] (interpose ", " x)))
>                ((fn [x] (apply println x))))
>
>    And I found the "->" notation marginally easier to interpret and
> understand. Apart from appearance, are there any benefits to using ->
> instead of the comp function? I happily concede that there exist nicer
> ways to achieve this goal, but the question I wanted to raise
> concerned the benefits of using -> vs comp or vice-versa.
>
> Kev
>
> Kev
> >
>

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To post to this group, send email to clojure@googlegroups.com
To unsubscribe from this group, send email to 
clojure+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/clojure?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to