Why should (every? string? []) yield true?

后端 未结 6 1489
说谎
说谎 2021-01-11 13:44

Looking at the source code for every? makes clear why

(every? string? []) => true

This is because every?

6条回答
  •  日久生厌
    2021-01-11 14:22

    It comes down to the identity values for the "and" and "or" operations. For any boolean B, it is the case that B has the same value as B & T. Thus, an "and" of no values must be true. Similarly, it is also true that B | F has the same value as B, so an "or" of no values is false.

    In a similar vein, the product of no terms is 1 and the sum of no terms is 0, those being the identity values for the multiplication and addition operators.

提交回复
热议问题