Hey all,

pallet.thread-expr contains arg->, which can be used liked (-> 1 (arg-> [x]
(+ x))) => 2.

Here's the library, with a bunch of other threading macros:
https://github.com/pallet/thread-expr

and the implementation of that particular one:

(defmacro arg->
  "Lexically assign the threaded argument to the specified symbol.

       (-> 1
         (arg-> [x] (+ x)))

       => 2"
  [arg [sym] & body]
  `(let [~sym ~arg]
     (-> ~sym ~@body)))


I've also added versions of all of these for last argument threading on this
branch <https://github.com/pallet/thread-expr/tree/feature/last-threader>.

On Fri, May 27, 2011 at 4:00 AM, Sunil S Nandihalli <
[email protected]> wrote:

> (defmacro thrush-with-sym [[sym] first & exprs]
>   (if (seq exprs) `(let [~sym ~first] (thrush-with-sym [~sym] ~@exprs))
> first))
>
> a small variation with the ability to chose any symbol for intermediate
> values.. Just thought of sharing it ...
>
>
> Thanks,
> Sunil.
>
> On Fri, May 27, 2011 at 1:15 PM, Meikel Brandmeyer <[email protected]> wrote:
>
>> Hi,
>>
>> the ~ in front of first is too much, because first is not in a
>> syntax-quote. Also I wouldn't capture var because it is special form.
>>
>> (defmacro bound->
>>   [fst & more]
>>   (if (seq more)
>>     `(let [~'v ~fst]
>>        (bound-> ~@more))
>>     fst))
>>
>>
>> Sincerely
>> Meikel
>>
>>  --
>> You received this message because you are subscribed to the Google
>> Groups "Clojure" group.
>> To post to this group, send email to [email protected]
>> Note that posts from new members are moderated - please be patient with
>> your first post.
>> To unsubscribe from this group, send email to
>> [email protected]
>> 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 post to this group, send email to [email protected]
> Note that posts from new members are moderated - please be patient with
> your first post.
> To unsubscribe from this group, send email to
> [email protected]
> 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 post to this group, send email to [email protected]
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Reply via email to