0 0

Clojure: (apply map + '((1 2 ) (3 4) (5 6)))5

In Clojure,
  (apply map + '((1 2 ) (3 4) (5 6)))


produce result:
 (6 9) 


Can anyone help me to understand how does it work?
Thank you in advance!

FP 
2009年8月19日 15:18

2个答案 按时间排序 按投票排序

0 0

采纳的答案

I belive the expression

(apply map + '((1 2 ) (3 4) (5 6)))

evaluates to:
(9 12)

instead of (6 9), which is the same with Scheme. What version of Clojure are you using?

The expression is pretty much equivalent to the following:
(map + '(1 2) '(3 4) '(5 6))

Take a look at this page, look for the part that explains "map".

2009年8月19日 18:24
0 0

E:\clojure>java -jar clojure-1.0.0.jar
Clojure 1.0.0-
user=> (apply map + '((1 2 ) (3 4) (5 6)))
(9 12)
user=>


can't reproduce (6, 9) ……

2009年8月19日 19:50

相关推荐

Global site tag (gtag.js) - Google Analytics