“减少"或“申请"在 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/and
".如何在不编写样板代码的情况下应用这些逻辑函数(宏)?
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屋!
查看全文