Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why "and []" is True and "or []" is False

Why "and" on an empty list returns true, does it imply that an empty list holds True? Sorry but I cannot read and comprehend this correctly, so please correct me. Thanks.

Prelude> and []
True
Prelude> or []
False
like image 707
Rohit Sharma Avatar asked Aug 21 '14 13:08

Rohit Sharma


People also ask

Why is false && false false?

If the left side of the expression is "truthy", the expression will return the right side. That's it. So in false && false , the left side is "falsey", so the expression returns the left side, false .

What is true && true?

true && true give true.

What does true and false return?

The true operator returns the bool value true to indicate that its operand is definitely true. The false operator returns the bool value true to indicate that its operand is definitely false. The true and false operators are not guaranteed to complement each other.

What does false and false evaluate to?

TRUE (say: not true) to evaluate to FALSE and ! FALSE (say: not false) to evaluate to TRUE. Try using the NOT operator and the equals operator to find the opposite of whether 5 is equal to 7.


1 Answers

and means: "Is everything there True?". When it's empty, everything's that is in there (which isn't much) is true, so that's a yes (True).

or means: "Is anything there True?". When there's nothing there, there's nothing true there. (False)

like image 56
yairchu Avatar answered Sep 21 '22 00:09

yairchu