mapv do the eval.

Should be a reflex: when something works in the repl, but not in the 
code...it's lazy !

Thanks

Le mardi 31 juillet 2012 14:07:17 UTC+2, Baishampayan Ghose a écrit :
>
> Hi, 
>
> map in Clojure (and ClojureScript) is lazy. Since you are not using 
> the return value of the mapping, it's not doing much at all. 
>
> You can force realization of a lazy sequence by putting a (doall... 
> around the map call. 
>
> You can also use mapv (in Clojure 1.4 at least) which will return a 
> vector instead of a lazy sequence. 
>
> Regards, 
> BG 
>
> On Tue, Jul 31, 2012 at 5:31 PM, Pierre-Henry Perret <phper...@gmail.com> 
> wrote: 
> > Evaluating this form: 
> > _________________________________ 
> > (dispatch/react-to #{:dom-loaded} 
> >                    (fn [t d] (do 
> >                                 (load-todos!)     ;; init !todos  OK 
> >                                 (log-console (str "todos=" @!todos))  ;; 
> OK 
> >                                 (map #(add-field! (:title %)) 
> @!todos)))) 
> > ;; not evaluated 
> > ___________________________________ 
> > 
> > the last expr is not evaluated : the side effect is on another atom 
> > variable. When this last expr evaluated outside in the repl, it does the 
> job 
> > 
> > Why is that last expr not evaluated in the reactor ? 
> > 
> > -- 
> > 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 
>
>
>
> -- 
> Baishampayan Ghose 
> b.ghose at gmail.com 
>

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