Is every thing in the empty list (null) a number?

  • A: Yes: Got to be good-looking 'cause it's so hard to see.
  • B: No: There is nothing in the empty list that could be a number.
  • C: Maybe: Depends on the implementation.
  • D: Error: null is an improper argument to every.
  • E: WTF: I thought this was CS, not Philosophy.

    Answer: A

    every is an and over a set of items: every(p, lst) = p(lst1) && p(lst2) && ... && p(lstn) = p(lst1) ∧ p(lst2) ∧ ... ∧ p(lstn) .

    The base case (identity or idempotent value) for and is true, since (x && true) = x, so every should return true as its base case when the list is empty.

    Contents    Page-10    Prev    Next    Page+10    Index