“减少”或“应用”在Clojure中使用逻辑函数 [英] "reduce" or "apply" using logical functions in Clojure
本文介绍了“减少”或“应用”在Clojure中使用逻辑函数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我不能在Clojure(1.2)的一系列布尔中使用逻辑函数。由于逻辑函数是宏,因此下面两个都不起作用:
I cannot use logical functions on a range of booleans in Clojure (1.2). Neither of the following works due to logical functions being macros:
(reduce and [... sequence of bools ...])
(apply or [... sequence of bools ...])
错误消息说,我不能采取宏的价值:#'clojure.core /和
。如何应用这些逻辑函数(宏)而不编写样板代码?
The error message says that I "can't take value of a macro: #'clojure.core/and
". How to apply these logical functions (macros) without writing boilerplate code?
推荐答案
不要使用
Don't -- use every?
and some
instead.
这篇关于“减少”或“应用”在Clojure中使用逻辑函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文