Re: confused about the scope of variables, or is it something else? ClojureScript

2012-12-04 Thread Balint Erdi
As Sean suggested you should use doseq instead of for and map to force side-effects: http://clojuredocs.org/clojure_core/clojure.core/doseq Since doseq uses the exact same syntax as for, you should just write doseq in its place. map should be converted to doseq syntax, too. Balint On Monday,

Re: confused about the scope of variables, or is it something else? ClojureScript

2012-12-03 Thread Arash Bizhan zadeh
So what should I do? would using fmap helps? I have used let initially, but I moved away to make it as close as possible to my repl code/. On Sunday, December 2, 2012 8:31:55 PM UTC-5, Sean Corfield wrote: Part of it is laziness: map is lazy so it doesn't do anything unless you use the

confused about the scope of variables, or is it something else? ClojureScript

2012-12-02 Thread Arash Bizhan zadeh
I am playing with clojurescript, and I have this code: (defn prepare [number] (def targets (take 4 (drop (* 4 (- number 1)) (dom/getElementsByClass place-div (def target-objects (map #(make-target %) targets)) (for [drag draggables target target-objects] (.addTarget drag target))

Re: confused about the scope of variables, or is it something else? ClojureScript

2012-12-02 Thread Sean Corfield
Part of it is laziness: map is lazy so it doesn't do anything unless you use the result. In the REPL, you print the result so map runs across the whole sequence. In the function, only the last expression (draggables) is returned so it is the only thing fully evaluated. Your code is very