Not sure if I understand your question/problem but, this:

"How can I avoid the binding of changeling to the initial value of the
atom and have the anonymous function passed to map use the current
(possibly changed) value of changeling? "

You are binding a reference not the actual value of the atom. To pass
the value you would deref it with '@' -> #(foo % @changeling)

On Jan 18, 10:44 am, Andreas Kostler
<andreas.koestler.le...@gmail.com> wrote:
> Hi all,
> Suppose I have the following function:
> (defn foo [x changeling]
>   (cond
>     (= (first x) 'bar)
>       (map #(foo % changeling) (rest x))))
>
> (def foobar (atom {:something "in-here"}))
>
> Now, changeling gets bound to (atom {:something "in-here"}). The
> conditional in foo might contain another case that actually changes
> changeling.
> How can I avoid the binding of changeling to the initial value of the
> atom and have the anonymous function passed to map use the current
> (possibly changed) value of changeling?
> E.g. x is a list of functions working on changeling like (bar (add-to-
> changeling :something :else) (do-something-with-changeling)). So bar
> causes each of the elements of (rest x) to evaluate. add-something-to-
> changeling adds stuff to changeling, do-something-with-changeling does
> work depending on the recently added stuff.
> Andreas

-- 
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

Reply via email to