'doseq instead 'for works fine:

(doseq [y (range 1999 2011), w (range 1 52)] (print-data y w))

On Jul 7, 11:14 am, Stuart Halloway <stuart.hallo...@gmail.com> wrote:
> This usage of for is ill-advised: for is not a loop, it is a comprehension. 
> This will not do what you want if, for example, you assign the result of for 
> to a variable instead of entering it at the REPL.
>
> Nurullah's response on this thread shows a nice separation of building the 
> (lazy) structure and printing it.
>
> Stu
>
> > (for [y (range 1999 2011) w (range 1 52)] (println "year=" y "w=" w))
>
> > On Jul 7, 2010, at 10:47 AM, uap12 wrote:
>
> >> Hi!
> >> I try to make a printout witch vill have year 1999->2010 and every
> >> week
> >> Eg.
> >> Year=1999 Week=1
> >> Year=1999 Week=2
> >> Year=1999 Week=3
> >> Year=1999 Week=4
> >> ....
> >> Year=2000 Week=1
>
> >> I have made the program in java, but like to try making it in Clojure,
> >> but so far i have got
> >> ----------------------------------------------------------------------------------------------------------------------------------------------------
> >> (defn print-data [year week]
> >>        (println  (str  "Y=" year " W=" week)))
>
> >> // This would not work and  i can't find how to map (print-data with a
> >> external variabel and a range
> >> // I can set week to a fixed number but not.
> >> // Or is this the wrong way of doing it ??
>
> >> (defn print-data2 [year]
> >>        (map (print-data year *) (range 1 53 1)))
>
> >> (defn run []
> >> (map print-data2 (range 1999 2010 1) ) )
>
> >> The program vill call an externa system program, with year and week as
> >> input, but for this test i just
> >> like to write them...
>
> >> // Anders
>
> >> --
> >> 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

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