问题描述
查看每个的源代码?
可以清楚地说明为什么
Looking at the source code for every?
makes clear why
(every? string? []) => true
这是因为实施了个?
递归并使用(nil?(seq coll))
结束递归。但是,我的问题是,这种行为有什么意义?只是绊倒了。
This is because every?
is implemented recursively and uses (nil? (seq coll))
to end recursion. But, my question is, what sense does this behaviour make? Just tripped over that.
我已经使用
(and (seq x) (every? string? x))
推荐答案
因为功能与forall量化器相同。也就是说,最初假定它为true,并且谓词的每个应用都是试图证明其为false。存在量词(出于不一致的原因,在Clojure中称为 some
而不是 any?
)是相反的方法-它
Because it functions the same as the forall-quantifier. That is, it is initially assumed true and each application of the predicate is an attempt to prove it false. The existential quantifier (which is called some
rather than any?
in Clojure for inconsistencies sake) works the opposite way - it assumes false and each application of the predicate is an attempt to prove it true.
换句话说,总是有某些事物对所有事物都不是正确的,并且总是如此。假说某事对某事都不是。
In other words, it's always true that something is true for all of none, and it's always false that something is true for some of none.
这篇关于为什么(每个字符串?[])都产生true?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!