MathGroup Archive 2003

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Is it doable in Mathematica? How?


On Monday, March 3, 2003, at 04:25 AM, Konrad Den Ende wrote:

> I'd like to create a truth table for, say, A, B and C, as
> well as two different expression, say, A&&B&&C and
> (A||B) -> C. How do i go about that?
>
> I have tried Table, but since True/False are not allowed
> there i got stuck. The help in Mathematica was of little
> help in this case. Any hints or suggestions?
>
>

generatetruthtable[numvars_Integer, expr_] :=
TableForm[Table[Block[{tvalues = IntegerDigits[i,
     2, numvars] /. {1 ->True, 0 ->False}}, Append[tvalues, expr @@
               tvalues]], {i, 0, 2\^numvars - 1}], TableHeadings -> 
{None,
                  Append[Table["v" <> ToString[i], {
                     i, numvars}], ToString[Part[expr, 1]]]}]

Try generatetruthtable[3, #1 && #2 && #3 &] to get A&&B&&C.

Regards,

Sseziwa



  • Prev by Date: Re: How to evaluate a NIntegrate expression properly
  • Next by Date: RE: Speed Tips
  • Previous by thread: Re: Is it doable in Mathematica? How?
  • Next by thread: Re: Is it doable in Mathematica? How?