On Aug 19, 5:16 pm, Sean Devlin <francoisdev...@gmail.com> wrote:
> However, over time I found this signature did not work well with my
> code.  Often I would write something like this
>
> (map (comp (partial map (comp   #(str2/drop % 2)
>                                 #(str2/take % 5)))
>                 #(str2/split % #"\t"))
>         (split a-string #"[\n\r]"))
>
> This felt a little forced, and the methods don't compose very well.

On the other hand, here's another way of writing the above, using ->
with some added helpers:

    (defn each [coll f]
      (map f coll))

    (defmacro each-> [coll & body]
      `(each ~coll (fn [x#] (-> x# ~...@body))))

     (-> a-string
         (str2/split #"[\n\r]")
         (each-> (str2/split #"\t")
                 (each-> (str2/take 5)
                         (str2/drop 2))))

-SS
--~--~---------~--~----~------------~-------~--~----~
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
Note that posts from new members are moderated - please be patient with your 
first post.
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