That's a big relieve.
Thanks for the answer!
--
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 un
> When I run this expression:
> (map (fn [x] (println x) x) (range 5))
>
> I expect to get (0 1 2 3 4) but instead I get (0 1 2 3 4 0 1 2 3 4)
> It seems like the println output is included in the result list.
> Am I missing something?
The REPL is fooling you.
(def *x (map (fn
Hi,
When I run this expression:
(map (fn [x] (println x) x) (range 5))
I expect to get (0 1 2 3 4) but instead I get (0 1 2 3 4 0 1 2 3 4)
It seems like the println output is included in the result list.
Am I missing something?
--
You received this message because you are subscribed to the
Hi,
Am 28.12.2008 um 03:22 schrieb Mark Volkmann:
Here's a related problem. I have a sequence of strings and I'd like to
print each on a separate line. I know that this isn't the answer:
(force (map println results))
I'm not sure what else to try.
(doseq [x (range 3)] (println x))
(doseq [
Meikel's example works fine for strings:
user=> (doseq [s ["hi" "mum" "love u"]] (println s))
hi
mum
love u
nil
As does your map:
user=> (dorun (map println ["hi" "mum" "love u"]))
hi
mum
love u
nil
--~--~-~--~~~---~--~~
You received this message because yo
Here's a related problem. I have a sequence of strings and I'd like to
print each on a separate line. I know that this isn't the answer:
(force (map println results))
I'm not sure what else to try.
On Sat, Dec 27, 2008 at 10:12 AM, Meikel Brandmeyer wrote:
> Hi,
>
> Am 26.12.2008 um 21:43 schrie
Hi,
Am 26.12.2008 um 21:43 schrieb Mark Volkmann:
(for [x (range 3)] (println x))
for is not a looping construct. for is a list comprehension.
For side effects as above use doseq.
(doseq [x (range 3)] (println x))
Sincerely
Meikel
smime.p7s
Description: S/MIME cryptographic signature
On Fri, Dec 26, 2008 at 10:43 PM, Mark Volkmann
wrote:
>
> Why does
>
> (for [x (range 3)] (println x))
>
> output
>
> (0
> nil 1
> nil 2
> nil)
>
> when run in the REPL instead of
>
> 0
> 1
> 2
This is because println returns nil every time it's run.
user=> (println "test")
test
nil
user=>
Al
On Fri, 26 Dec 2008 14:43:23 -0600
"Mark Volkmann" wrote:
>
>Why does
>
>(for [x (range 3)] (println x))
>
>output
>
>(0
>nil 1
>nil 2
>nil)
>
>when run in the REPL instead of
>
>0
>1
>2
>
>and nothing at all when run from a script?
>
The seq of nils is the return value of `(for ...)'. It is pr
Why does
(for [x (range 3)] (println x))
output
(0
nil 1
nil 2
nil)
when run in the REPL instead of
0
1
2
and nothing at all when run from a script?
--
R. Mark Volkmann
Object Computing, Inc.
--~--~-~--~~~---~--~~
You received this message because you are s
10 matches
Mail list logo