1
$\begingroup$

Is there any simpler formula than

Tuples[{False, True}, 3]

to generate tuples of all combinations of boolean values?

$\endgroup$
  • 3
    $\begingroup$ In what way do you want it to be simpler? That looks like a very simple and efficient way to get what you are looking for. $\endgroup$ – Jason B. Mar 9 '15 at 8:32
7
$\begingroup$

As said in comments, that's an efficient way of generating combinations. If you want to do something with them, BooleanTable is pretty neat:

TableForm[
 BooleanTable[{{a, b, c}, And[a, b, c], Or[a, b, c], Xor[a, b, c], Xnor[a, b, c]}, {a, b, c}], 
 TableHeadings -> {None, {"Vars", "And", "Or", "Xor", "Xnor"}}]

enter image description here

$\endgroup$
  • $\begingroup$ that is neat! +1:) $\endgroup$ – ubpdqn Mar 9 '15 at 12:04
1
$\begingroup$

Just to give another way to this goal:

IntegerDigits[#, 2, 3] & /@ Range[2^3] /. {1 -> "True", 0 -> "False"}

;-)

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.