strange map

2013-08-28 Thread ljcppunix
Hi

(map #(do (print -) %) '(1 2 3 4 5)) 
I think the result should be (-1 -2 -3 -4 -5), but it is (--1 -2 -3 -4 5), 
it's difficult to understand, 
Can someone give 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 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/groups/opt_out.


Re: strange map

2013-08-28 Thread Christian Sperandio
Hi,

Try just one thing:

(def r (map #(do (print -) %) '(1 2 3 4 5)))

And after, do (println r)

What do you get?







2013/8/28 ljcppu...@gmail.com

 Hi

 (map #(do (print -) %) '(1 2 3 4 5))
 I think the result should be (-1 -2 -3 -4 -5), but it is (--1 -2 -3 -4 5),
 it's difficult to understand,
 Can someone give 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 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/groups/opt_out.


-- 
-- 
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/groups/opt_out.


Re: strange map

2013-08-28 Thread Alex Baranosky
map is lazy.  You shouldn't call side effect functions from it.  I
recommend you use doseq instead.


On Wed, Aug 28, 2013 at 1:57 AM, Christian Sperandio 
christian.speran...@gmail.com wrote:

 Hi,

 Try just one thing:

 (def r (map #(do (print -) %) '(1 2 3 4 5)))

 And after, do (println r)

 What do you get?







 2013/8/28 ljcppu...@gmail.com

 Hi

 (map #(do (print -) %) '(1 2 3 4 5))
 I think the result should be (-1 -2 -3 -4 -5), but it is (--1 -2 -3 -4
 5), it's difficult to understand,
 Can someone give 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 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/groups/opt_out.


  --
 --
 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/groups/opt_out.


-- 
-- 
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/groups/opt_out.


Re: strange map

2013-08-28 Thread ljcppunix
Hi,
  Nothing to get, Nothing to println, please give a detail, thank you.

On Wednesday, August 28, 2013 4:57:49 PM UTC+8, Christian Sperandio wrote:

 Hi,

 Try just one thing:

 (def r (map #(do (print -) %) '(1 2 3 4 5)))

 And after, do (println r)

 What do you get?







 2013/8/28 ljcp...@gmail.com javascript:

 Hi

 (map #(do (print -) %) '(1 2 3 4 5)) 
 I think the result should be (-1 -2 -3 -4 -5), but it is (--1 -2 -3 -4 
 5), it's difficult to understand, 
 Can someone give answer?
  
 -- 
 -- 
 You received this message because you are subscribed to the Google
 Groups Clojure group.
 To post to this group, send email to clo...@googlegroups.comjavascript:
 Note that posts from new members are moderated - please be patient with 
 your first post.
 To unsubscribe from this group, send email to
 clojure+u...@googlegroups.com javascript:
 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+u...@googlegroups.com javascript:.
 For more options, visit https://groups.google.com/groups/opt_out.




-- 
-- 
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/groups/opt_out.


Re: strange map

2013-08-28 Thread ljcppunix
 Right, thank you!

On Wednesday, August 28, 2013 4:59:33 PM UTC+8, Alex Baranosky wrote:

 map is lazy.  You shouldn't call side effect functions from it.  I 
 recommend you use doseq instead.


 On Wed, Aug 28, 2013 at 1:57 AM, Christian Sperandio 
 christian...@gmail.com javascript: wrote:

 Hi,

 Try just one thing:

 (def r (map #(do (print -) %) '(1 2 3 4 5)))

 And after, do (println r)

 What do you get?







 2013/8/28 ljcp...@gmail.com javascript:

 Hi

 (map #(do (print -) %) '(1 2 3 4 5)) 
 I think the result should be (-1 -2 -3 -4 -5), but it is (--1 -2 -3 -4 
 5), it's difficult to understand, 
 Can someone give answer?
  
 -- 
 -- 
 You received this message because you are subscribed to the Google
 Groups Clojure group.
 To post to this group, send email to clo...@googlegroups.comjavascript:
 Note that posts from new members are moderated - please be patient with 
 your first post.
 To unsubscribe from this group, send email to
 clojure+u...@googlegroups.com javascript:
 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+u...@googlegroups.com javascript:.
 For more options, visit https://groups.google.com/groups/opt_out.


  -- 
 -- 
 You received this message because you are subscribed to the Google
 Groups Clojure group.
 To post to this group, send email to clo...@googlegroups.comjavascript:
 Note that posts from new members are moderated - please be patient with 
 your first post.
 To unsubscribe from this group, send email to
 clojure+u...@googlegroups.com javascript:
 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+u...@googlegroups.com javascript:.
 For more options, visit https://groups.google.com/groups/opt_out.




-- 
-- 
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/groups/opt_out.


Re: strange map

2013-08-28 Thread ljcppunix
Hi 

user=  (def r (map #(do (print -) %) '(1 2 3 4 5)))
#'user/r
user= (println r)
(--1 -2 -3 -4 5)
nil

On Wednesday, August 28, 2013 4:57:49 PM UTC+8, Christian Sperandio wrote:

 Hi,

 Try just one thing:

 (def r (map #(do (print -) %) '(1 2 3 4 5)))

 And after, do (println r)

 What do you get?







 2013/8/28 ljcp...@gmail.com javascript:

 Hi

 (map #(do (print -) %) '(1 2 3 4 5)) 
 I think the result should be (-1 -2 -3 -4 -5), but it is (--1 -2 -3 -4 
 5), it's difficult to understand, 
 Can someone give answer?
  
 -- 
 -- 
 You received this message because you are subscribed to the Google
 Groups Clojure group.
 To post to this group, send email to clo...@googlegroups.comjavascript:
 Note that posts from new members are moderated - please be patient with 
 your first post.
 To unsubscribe from this group, send email to
 clojure+u...@googlegroups.com javascript:
 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+u...@googlegroups.com javascript:.
 For more options, visit https://groups.google.com/groups/opt_out.




-- 
-- 
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/groups/opt_out.


Re: strange map

2013-08-28 Thread ljcppunix
Hi 

user=  (def r (map #(do (print -) %) '(1 2 3 4 5)))
#'user/r
user= (println r)
(--1 -2 -3 -4 5)
nil

On Wednesday, August 28, 2013 4:57:49 PM UTC+8, Christian Sperandio wrote:

 Hi,

 Try just one thing:

 (def r (map #(do (print -) %) '(1 2 3 4 5)))

 And after, do (println r)

 What do you get?







 2013/8/28 ljcp...@gmail.com javascript:

 Hi

 (map #(do (print -) %) '(1 2 3 4 5)) 
 I think the result should be (-1 -2 -3 -4 -5), but it is (--1 -2 -3 -4 
 5), it's difficult to understand, 
 Can someone give answer?
  
 -- 
 -- 
 You received this message because you are subscribed to the Google
 Groups Clojure group.
 To post to this group, send email to clo...@googlegroups.comjavascript:
 Note that posts from new members are moderated - please be patient with 
 your first post.
 To unsubscribe from this group, send email to
 clojure+u...@googlegroups.com javascript:
 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+u...@googlegroups.com javascript:.
 For more options, visit https://groups.google.com/groups/opt_out.




-- 
-- 
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/groups/opt_out.


Re: strange map

2013-08-28 Thread Christian Sperandio
In fact, you mix the output in the REPL and the result of the map function.
The result of the map call is (1 2 3 4 5), but you have the print display
is managed by the repl and is done when is done :)

If you want as result a string with the negative value, you must do:

(map #(str - %) '(1 2 3 4 5))



2013/8/28 ljcppu...@gmail.com

 Hi

 user=  (def r (map #(do (print -) %) '(1 2 3 4 5)))
 #'user/r
 user= (println r)
 (--1 -2 -3 -4 5)
 nil

 On Wednesday, August 28, 2013 4:57:49 PM UTC+8, Christian Sperandio wrote:

 Hi,

 Try just one thing:

 (def r (map #(do (print -) %) '(1 2 3 4 5)))

 And after, do (println r)

 What do you get?







 2013/8/28 ljcp...@gmail.com

 Hi

 (map #(do (print -) %) '(1 2 3 4 5))
 I think the result should be (-1 -2 -3 -4 -5), but it is (--1 -2 -3 -4
 5), it's difficult to understand,
 Can someone give answer?

 --
 --
 You received this message because you are subscribed to the Google
 Groups Clojure group.
 To post to this group, send email to clo...@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+u...@**googlegroups.com

 For more options, visit this group at
 http://groups.google.com/**group/clojure?hl=enhttp://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+u...@**googlegroups.com.

 For more options, visit 
 https://groups.google.com/**groups/opt_outhttps://groups.google.com/groups/opt_out
 .


  --
 --
 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/groups/opt_out.


-- 
-- 
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/groups/opt_out.


Re: strange map

2013-08-28 Thread Cedric Greevey
I'm pretty sure the OP is experimenting to see when items are realized, and
wants to know why it's peeking ahead one item. Most likely map is seeing
if the next part is empty.


On Wed, Aug 28, 2013 at 5:39 AM, Christian Sperandio 
christian.speran...@gmail.com wrote:

 In fact, you mix the output in the REPL and the result of the map
 function.
 The result of the map call is (1 2 3 4 5), but you have the print display
 is managed by the repl and is done when is done :)

 If you want as result a string with the negative value, you must do:

 (map #(str - %) '(1 2 3 4 5))



 2013/8/28 ljcppu...@gmail.com

 Hi

 user=  (def r (map #(do (print -) %) '(1 2 3 4 5)))
 #'user/r
 user= (println r)
 (--1 -2 -3 -4 5)
 nil

 On Wednesday, August 28, 2013 4:57:49 PM UTC+8, Christian Sperandio wrote:

 Hi,

 Try just one thing:

 (def r (map #(do (print -) %) '(1 2 3 4 5)))

 And after, do (println r)

 What do you get?







 2013/8/28 ljcp...@gmail.com

 Hi

 (map #(do (print -) %) '(1 2 3 4 5))
 I think the result should be (-1 -2 -3 -4 -5), but it is (--1 -2 -3 -4
 5), it's difficult to understand,
 Can someone give answer?

 --
 --
 You received this message because you are subscribed to the Google
 Groups Clojure group.
 To post to this group, send email to clo...@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+u...@**googlegroups.com

 For more options, visit this group at
 http://groups.google.com/**group/clojure?hl=enhttp://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+u...@**googlegroups.com.

 For more options, visit 
 https://groups.google.com/**groups/opt_outhttps://groups.google.com/groups/opt_out
 .


  --
 --
 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/groups/opt_out.


  --
 --
 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/groups/opt_out.


-- 
-- 
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/groups/opt_out.