They are lazy -- change "for" to "doseq"....

________________________________________
From: clojure@googlegroups.com [clojure@googlegroups.com] on behalf of Kevin 
Kleinfelter [kleinfelter.gro...@gmail.com]
Sent: 17 May 2017 19:14
To: Clojure
Subject: Let and For Doesn't Execute - Where Is My Misunderstanding?

I'm stumped by the behavior of the following code fragment.  Can someone help 
me understand what's happening?

This code:
  (println "Holding:" (:class holding))
  (let [t (:class holding)]
      (for [x t] (println "here" x))
      (for [x t] (println "there" x))))

Produces this output:
holding: {:fundname Mutual Fund 1, :value 123.45, :class [{:class sell-me, 
:percent 100}]}
class: [{:class sell-me, :percent 100}]
Holding: [{:class sell-me, :percent 100}]
there {:class sell-me, :percent 100}

Why doesn't the 'for' with "here" print anything?

I tried wrapping the fors with a do, but the output was the same:
  (println "class:" (:class holding))
  (let [t (:class holding)]
    (do
        (for [x t] (println "here" x))
        (for [x t] (println "there" x)))))

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 unsubscribe from this group and stop receiving emails from it, send an email 
to 
clojure+unsubscr...@googlegroups.com<mailto: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