Hi Jay
Thanks for the reply. I did not know how as-> works, till I saw your
example. I myself need to many a times chain things where in some cases the
variable will go at the first location and in another cases it will go to
the last location and it was a big pain to do something like what you
On Mon, Aug 19, 2013 at 6:41 PM, Anand Prakash wrote:
> What is the major benefit of as->
>
> => (-> 4 (#(* % %)) (+ 12) )
>
> 28
>
> => (-> 4 (as-> y (* y y)) (+ 12))
>
> 28
Solving the contrived example doesn't really help answer the original
question of preference and tradeoffs. As to the bene
What is the major benefit of as->
=> (-> 4 (#(* % %)) (+ 12) )
28
=> (-> 4 (as-> y (* y y)) (+ 12))
28
On Monday, August 19, 2013 9:13:36 AM UTC-7, Ben Mabey wrote:
>
> On 8/19/13 8:58 AM, Jay Fields wrote:
> > In the past, I've written code like the following
> >
> > (defn foo [x y]
> >
While I don't think I'd use it in your particular example, I like it when
it can eliminate superfluous let bindings.
(let [z (as-> (* x x) xsq
...)]
...)
On Mon, Aug 19, 2013 at 10:58 AM, Jay Fields wrote:
> In the past, I've written code like the following
>
> (defn foo [x y]
>
I personally think the only place as-> should be used is inside other
threading macros. When it's used anywhere else, the name-goes-second
ordering feels wrong and very awkward.
On Mon, Aug 19, 2013 at 9:58 AM, Jay Fields wrote:
> In the past, I've written code like the following
>
> (defn foo
I think a regular "let" is clearer in this kind of case.
"as->" suggests to me that multiple rebindings will happen to the name: if
that is not happening then it is confusing for readers IMHO.
The only case I can think of where "as->" makes sense and the binding only
happens once is if you are
On 8/19/13 8:58 AM, Jay Fields wrote:
In the past, I've written code like the following
(defn foo [x y]
(let [x-squared (* x x)]
(if (pos? y)
(+ x-squared y)
(- x-squared y
However, the introduction of as-> has led me to write the following, at times
(defn foo [x y]