Thanks

I change the function with this one

(defn testdoseq []
  (do
    (doseq [x '("a" "b" "c")]
      (fn1 x)
      )
    (doseq [x '("1" "2" "3")]
      (fn2 x)
      )
  ))

On 17 juin, 20:26, Aaron Cohen <aa...@assonance.org> wrote:
> On Fri, Jun 17, 2011 at 2:13 PM, FD <fabien.dub...@scarlet.be> wrote:
> > Hello,
>
> > What is wrong in this function?
>
> > (defn testmap []
> >  (do
> >    (map #(fn1 %)
> >       '("a" "b" "c"))
> >    (map #(fn2%)
> >       '("1" "2" "3"))
> >  ))
>
> 1) "for" is lazy, its value is a LazySeq and the contents are only
> evaluated at need
> 2) The return value of "do" is the last statement executed
> 3) As a result, the resul of "testmap" is a LazySeq containing ("1"
> "2" "3"), the first LazySeq is discarded.
> 4) At the repl, the second LazySeq is printed because it's the result
> of calling testmap. As each entry is lazily realized, the println call
> prints "1" and the repl prints the return value of "println", which is
> nil.
>
>
>
>
>
>
>
> > If fn1 = fn2 = println
> > the result is
> > (1
> > 2
> > nil 3
> > nil nil)
>
> > I expected this result
> > a
> > b
> > c
> > 1
> > 2
> > 3
>
> > Thanks
>
> > --
> > 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 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