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

后端 未结 6 1460
说谎
说谎 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:37

    It is defined so in mathemathics an there is a good reason for that. It would be a consistency disaster if every? was defined any other way.

    With current definition the result of concatenation satisfies every? foo if and only if all concatenated collections also satisfy every? foo. Making every? return false on empty lists would break this convenient equivalence and a host of others (e.g. removal of an element would sometimes lead to switching every? from true to false.)

提交回复
热议问题