On Jul 7, 5:06 pm, Isak Hansen wrote:
> On Wed, Jul 7, 2010 at 5:00 PM, Lars Nilsson wrote:
>
> > Maybe
>
> > (doseq [year (range 1999 2010 1)]
> > (doseq [month (range 1 53 1)]
> > (print-data year range)))
>
> You could also do this with dotimes instead of doseq. Doesn't matter
> for Ns thi
On Wed, Jul 7, 2010 at 5:00 PM, Lars Nilsson wrote:
>
> Maybe
>
> (doseq [year (range 1999 2010 1)]
> (doseq [month (range 1 53 1)]
> (print-data year range)))
>
You could also do this with dotimes instead of doseq. Doesn't matter
for Ns this small, but creating a range just so you have somet
Hi,
Am 07.07.2010 um 18:04 schrieb Greg:
>> If you don't need the intermediate seq you can use doseq directly:
>>
>> (doseq [y (range 1999 2011)
>> w (range 1 53)]
>> (println "Year" y "Week" w))
>
> That's really cool, I didn't know you can do that.
for and doseq are quite similar in it
> If you don't need the intermediate seq you can use doseq directly:
>
> (doseq [y (range 1999 2011)
>w (range 1 53)]
> (println "Year" y "Week" w))
That's really cool, I didn't know you can do that.
I just looked over its implementation and it seems pretty complex but
interesting, so
'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 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
Oh, sorry, I misread, I thought you said "*The* usage of for is ill-advised" :-p
- Greg
On Jul 7, 2010, at 11:27 AM, Greg wrote:
> On Jul 7, 2010, at 11:14 AM, Stuart Halloway wrote:
>
>> This usage of for is ill-advised: for is not a loop, it is a comprehension.
>> This will not do what you w
On Jul 7, 2010, at 11:14 AM, Stuart Halloway 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 th
Hi,
Am 07.07.2010 um 17:10 schrieb Nurullah Akkaya:
> (doseq [[y w] (for [y (range 1999 2011)
> w (range 1 53)] [y w])]
> (println "Year " y "Week " w))
And just for the record:
If you don't need the intermediate seq you can use doseq directly:
(doseq [y (range 199
or rather
(for [y (range 1999 (inc 2010))
w (range 1 (inc 52))] [y w])
which remove the 2011 and 53 magic values ;-)
2010/7/7 Nurullah Akkaya :
> You can build a sequence of year week pairs using,
>
> (for [y (range 1999 2011)
> w (range 1 53)] [y w])
>
> then you can iterate over th
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
You can build a sequence of year week pairs using,
(for [y (range 1999 2011)
w (range 1 53)] [y w])
then you can iterate over that and print,
(doseq [[y w] (for [y (range 1999 2011)
w (range 1 53)] [y w])]
(println "Year " y "Week " w))
Hope it helps...
--
On Wed, Jul 7, 2010 at 10:47 AM, uap12 wrote:
> I have made the program in java, but like to try making it in Clojure,
> but so far i have got
>
> (d
(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 We
(defn print-data2 [year]
(dorun (map #(print-data year %) (range 1 53 1
I think you have both a problem with the syntax of anonymous functions and a
problem of lazyness.
map only creates a lazy seq that do not get evaluated.
dorun do that
You can have a look at list comprehensions (f
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
---
15 matches
Mail list logo