Hi,
On May 31, 10:43 am, Konrad Hinsen <[email protected]> wrote:
> The two expressions are equivalent. However, there is a difference
> when you use let outside of a function definition:
I disagree. The two expressions are not equivalent and you actually
provide the explanation, why they are not. The defn does really make a
difference. (#() is the "defn")
user=> (def *cfg* {:word "tom"})
#'user/*cfg*
user=> (def s (filter #(= (:word *cfg*) %) (list "tom" "eat")))
#'user/s
user=> (def t (let [word (:word *cfg*)] (filter #(= word %) (list
"tom" "eat"))))
#'user/t
user=> [(first s) (first t)]
["tom" "tom"]
user=> (binding [*cfg* {:word "eat"}] [(fnext s) (fnext t)])
["eat" nil]
Note: I use list instead of the usual vector to avoid chunked seq
evaluation.
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