Arc Forumnew | comments | leaders | submitlogin
1 point by etfb 6170 days ago | link | parent

It's basically saying: if any of my operands are nil, return nil; otherwise, return the final operand. So (and 1 2 3 4 5) should return 5, because none of those numbers is nil. But (and 1 2 nil 4 5) will return nil.

Incidentally, it only evaluates as far as it has to. (and (a) (b) (c)) will evaluate (a), then if the result is non-nil it will evaluate (b), then if the result of that is also non-nil it will evaluate (c) and return the answer to that last evaluation as the result of the whole expression.

This is different to a hypothetical bitwise and, which would evaluate at least until it reached zero, "and"ing the bits together as it goes. So (bitand 42 23), which is (bitand 101010 010111) in binary, would return 2, which is 000010 in binary. That's not what (and...) does.