On Aug 20, 8:26 am, Stuart Sierra <the.stuart.sie...@gmail.com> wrote:
> Seems like opinion is pretty evenly divided here.  I'll leave the
> library as-is for now, give it some time to see how things play out.
>
> In the mean time, as a compromise, I've added str-utils2/partial,
> which is like clojure.core/partial for functions that take their
> primary argument first.
>
> (str2/partial str2/take 2)
> ;;=> (fn [s] (str2/take s 2))
>
> Now you can compose these using comp, map, whatever.
>
> -SS
I've never really used the partial function before, but it seems that
it should be fairly easy to write a macro that lets you replace
certain arguments.

Usage would be (partial* fun _data 1 :test _index) returning something
like (fn [_data _index] (fun _data 1 :test _index))
So you get back a 2 arg function with some parameters already filled
in by either constant data or closed over bindings.  The macro would
need to use some sort of convention to recognize which symbols are
meant to be used in the new function arglist, I've used _ as the
prefix.  I don't have time right now to actually write the macro :)

Brad
--~--~---------~--~----~------------~-------~--~----~
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