Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/clojure/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Function 在clojure函数中使用过滤器_Function_Clojure - Fatal编程技术网

Function 在clojure函数中使用过滤器

Function 在clojure函数中使用过滤器,function,clojure,Function,Clojure,为什么 给予 02468 但是 给予 ? 您的匿名函数中存在一个问题-让我们以更可读的方式编写它: (0 1 2 3 4 5 6 7 8 9) 现在,我认为它返回整个范围序列的原因很明显:范围10的值绑定到参数x,并作为函数的结果返回 正确的版本是: ((fn [x] (do filter even? x)) (range 10)) 非常感谢你对Piotrek回答的评论,它解决了你的问题。因此,请接受它。 (0 1 2 3 4 5 6 7 8 9) ((

为什么

给予 02468

但是

给予


?

您的匿名函数中存在一个问题-让我们以更可读的方式编写它:

(0 1 2 3 4 5 6 7 8 9)
现在,我认为它返回整个范围序列的原因很明显:范围10的值绑定到参数x,并作为函数的结果返回

正确的版本是:

((fn [x]
   (do filter
       even?
       x))
 (range 10))

非常感谢你对Piotrek回答的评论,它解决了你的问题。因此,请接受它。
(0 1 2 3 4 5 6 7 8 9)
((fn [x]
   (do filter
       even?
       x))
 (range 10))
((fn [x] (filter even? x))
 (range 10))
;; => (0 2 4 6 8)