You can also use as-> in 1.5+

(-> 2
    (+ 2)
    (as-> x (* 1 x 3)))

I like this a bit more than the (#()) approach, personally

On Sat, Jan 18, 2014 at 12:07 AM, Alex Baranosky
<alexander.barano...@gmail.com> wrote:
> What I think is the interesting part of the question is the inclusion of the
> word "idiomatic". I'm not sure swiss-arrows is idiomatic... that said I
> don't know what would be considered idiomatic here.a
>
> One solution I know of for examples like this is:
>
> (-> 2
>      (+ 2)
>      (#(* 1 % 3)))
>
> I'm not sure this is idiomatic either, but it at least has the benefit of
> requiring no additional dependencies.
>
>
>
> On Fri, Jan 17, 2014 at 11:29 PM, t x <txrev...@gmail.com> wrote:
>>
>> You win. :-)
>>
>>
>> On Fri, Jan 17, 2014 at 11:26 PM, Shaun Gilchrist <shaunxc...@gmail.com>
>> wrote:
>>>
>>> https://github.com/rplevy/swiss-arrows
>>>
>>>
>>> On Fri, Jan 17, 2014 at 11:05 PM, t x <txrev...@gmail.com> wrote:
>>>>
>>>> I have the following:
>>>>
>>>> (defn helper [initial funcs]
>>>>   (loop [fns funcs
>>>>          ans initial]
>>>>     (if (empty? fns)
>>>>       ans
>>>>       (recur (rest fns)
>>>>              (list (first fns) ans)))))
>>>>
>>>> (defmacro => [initial & funcs]
>>>>   (helper initial funcs))
>>>>
>>>> (macroexpand-1
>>>>  '(=> 2
>>>>       #(+ % 2)
>>>>       #(* 1 % 3)))
>>>>
>>>>
>>>> Is there something part of the idiomatic clojure / clojure core which
>>>> does the above? Basically, I like the idea of -> and -->, but I find that I
>>>> can't always guarantee (1) last element or (2) 2nd element.
>>>>
>>>> The above lets me place the argument directly via #%
>>>>
>>>> Question: is there something part of idiomatic clojure / clojure core
>>>> that already does the above?
>>>>
>>>> Thanks!
>>>>
>>>> --
>>>> --
>>>> 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
>>>> ---
>>>> You received this message because you are subscribed to the Google
>>>> Groups "Clojure" group.
>>>> To unsubscribe from this group and stop receiving emails from it, send
>>>> an email to clojure+unsubscr...@googlegroups.com.
>>>> For more options, visit https://groups.google.com/groups/opt_out.
>>>
>>>
>>> --
>>> --
>>> 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
>>> ---
>>> You received this message because you are subscribed to the Google Groups
>>> "Clojure" group.
>>> To unsubscribe from this group and stop receiving emails from it, send an
>>> email to clojure+unsubscr...@googlegroups.com.
>>> For more options, visit https://groups.google.com/groups/opt_out.
>>
>>
>> --
>> --
>> 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
>> ---
>> You received this message because you are subscribed to the Google Groups
>> "Clojure" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to clojure+unsubscr...@googlegroups.com.
>> For more options, visit https://groups.google.com/groups/opt_out.
>
>
> --
> --
> 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
> ---
> You received this message because you are subscribed to the Google Groups
> "Clojure" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to clojure+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.

-- 
-- 
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
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to