On Fri, Nov 30, 2012 at 10:15 AM, Alex Baranosky
<alexander.barano...@gmail.com> wrote:
> I've got a utility function I've been using called `conditionally-transform`
> which is a non-macro version of `test->`.

Likewise, except with use a HOF:

(defn conditionalize [pred f]
  (fn [& args] (if (apply pred args) (apply f args) (apply identity args))))

Jay's example would then be (-> x ((conditionalize number? str))
(conditionalize string? count))).

-- 
Ben Wolfson
"Human kind has used its intelligence to vary the flavour of drinks,
which may be sweet, aromatic, fermented or spirit-based. ... Family
and social life also offer numerous other occasions to consume drinks
for pleasure." [Larousse, "Drink" entry]

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