Of course, the use of let does not make the code any more imperative or
less functional, as long as there are no side effects. Also, the scope is
limited to the let block, keeping it "clean," and there should be no harm
to performance.
IMHO, the code with let is simply more readable and therefore
There's also a middle ground:
(defn my-fn2 [input]
(op5
(op4
(op1 input)
(op2 input
If your "op" names are descriptive, this can still be very easy to
read, with significantly fewer characters than the "let" version
(you'll get use to reading inside-out quickly). You can also
Hello,
I fear there isn't (at least for me) a simple general answer for such a
general problem, because :
* it will really depend on the context : are op1 and op2 themselves cryptic
names that would benefit from having their result clearly named ? are op1
and op2 "low level operations" for which
You should look at "->"
it lest you take (op3 (op2 (op1 input))) and write it as (-> input op1 op2 op3)
there is also "comp" which composes functions, and partial for partial
application.
some example comp usage:
http://github.com/hiredman/clojurebot/blob/297e266b0badf0f301a556e95771b940a80016e7/
Very interesting ideas, everyone... thanks a lot for the input.
Yeah, I recognize that each case is going to be different - I guess I
was just looking for suggestions on how to manage it. Which I found...
Comp and partial look particularly interesting. Thanks!
-Luke
On Feb 25, 5:09 pm, Kevin Do
On Wed, Feb 25, 2009 at 4:11 PM, Jason Wolfe wrote:
> (you'll get use to reading inside-out quickly).
As a Java/Ruby guy who is not used to reading inside out, I'm curious
as to whether people who ARE accustomed to LISP find the -> macro
distracting since it flops things around. Are there circum
On Feb 27, 6:39 pm, "John D. Hume" wrote:
> As a Java/Ruby guy who is not used to reading inside out, I'm curious
> as to whether people who ARE accustomed to LISP find the -> macro
> distracting since it flops things around. Are there circumstances
> where you prefer it?
It's pretty useful for
>
> It's pretty useful for nested keywords:
>
> (:name (:profile (:user message)))
>
> (-> message :user :profile :name)
>
> - James
That is really cool. Once again the language and the community impress
me with how elegant the language is.
Allen
--~--~-~--~~~--
On Feb 27, 1:39 pm, "John D. Hume" wrote:
> As a Java/Ruby guy who is not used to reading inside out, I'm curious
> as to whether people who ARE accustomed to LISP find the -> macro
> distracting since it flops things around. Are there circumstances
> where you prefer it?
Definitely. When you'r
2009/2/28 Stuart Sierra
>
> On Feb 27, 1:39 pm, "John D. Hume" wrote:
> > As a Java/Ruby guy who is not used to reading inside out, I'm curious
> > as to whether people who ARE accustomed to LISP find the -> macro
> > distracting since it flops things around. Are there circumstances
> > where yo
First, I have to say thanks. I'm only a part-time Clojure user, and I
didn't know of the -> macro until today. Second, I think the ->
syntax leads to more readable code for precisely those situations
where you're coding a sequence of actions. Finally, I've got a
comment about what I think might
Hi,
Am 01.03.2009 um 02:19 schrieb Belfabius:
I quickly learned the -> macro can't be used in the same way for one
simple reason; the value that is threaded through to the forms is
always placed in the first argument position. How about adding a
macro -- it could be called |> just as in F# --
12 matches
Mail list logo