Also remember that `mapv` is not lazy and will force the map to run right
away, which helps if side-effecty things like `println` are a part of the
function.

On Thu, Feb 7, 2019 at 10:54 AM Justin Smith <noisesm...@gmail.com> wrote:

> also do note that clojure.core/run! is designed for two-arg map when
> it's only run for side effects, and clojure.core/doseq is designed for
> nested side-effecting iteration
>
> On Thu, Feb 7, 2019 at 3:33 AM Pierpaolo Tofani
> <pierpaolo.tof...@gmail.com> wrote:
> >
> > Thanks ! Your diagnosis is correct. With two dorun works fine.
> >
> > Il giorno giovedì 7 febbraio 2019 12:19:40 UTC+1, Orestis Markou ha
> scritto:
> >>
> >> Without having ran your code, it seems that the inner map is not
> wrapped in a doall, so while the outer lazy-seq is forced, the inner is not.
> >>
> >> This might be of interest to you:
> http://clojure-doc.org/articles/language/laziness.html
> >>
> >> If you only want to do map for side effects, you could use dorun
> instead of doall.
> >>
> >> On 7 Feb 2019, at 12:04 PM, Pierpaolo Tofani <pierpaol...@gmail.com>
> wrote:
> >>
> >> Hi
> >> i am new in clojure sorry.
> >> In the snippet of code i used two map functions only to produce side
> effects on two ref.
> >> Even using doall no affect is produced on ref aaa and zzz, seems that
> the sequence is still lazy.
> >> But if i remove the final :done , and the repl show me the sequence
> produced (that i don't care) the ref aaa and zzz are affected.Thanks in
> advance.
> >> PS The two map are in effect doing a for.
> >>
> >> (def aaa (ref 0))
> >> (def zzz (ref 0))
> >> (def s1 [1 2 3 4 5])
> >> (def s2 [1 2 3 4 5])
> >> (defn make-side []
> >> (do
> >> (doall
> >> (map
> >>   (fn [x]
> >>     (map
> >>       (fn [y]
> >>         (dosync
> >>           (alter aaa inc)
> >>           (alter zzz dec)
> >>         )
> >>         )
> >>       s2))
> >>   s1)
> >> )
> >> :done
> >> )
> >> )
> >>
> >>
> >> --
> >> You received this message because you are subscribed to the Google
> >> Groups "Clojure" group.
> >> To post to this group, send email to clo...@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+u...@googlegroups.com
> >> For more options, visit this group at
> >> http://groups.google.com/group/clojure?hl=en
> >> ---
> >> You received this message because you are subscribed to the Google
> Groups "Clojure" group.
> >> To unsubscribe from this group and stop receiving emails from it, send
> an email to clojure+u...@googlegroups.com.
> >> For more options, visit https://groups.google.com/d/optout.
> >>
> >>
> > --
> > 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
> > ---
> > You received this message because you are subscribed to the Google
> Groups "Clojure" group.
> > To unsubscribe from this group and stop receiving emails from it, send
> an email to clojure+unsubscr...@googlegroups.com.
> > For more options, visit https://groups.google.com/d/optout.
>
> --
> 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
> ---
> You received this message because you are subscribed to the Google Groups
> "Clojure" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to clojure+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
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
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to