Re: Is it doable in Mathematica? How?
- To: mathgroup at smc.vnet.net
- Subject: [mg39751] Re: Is it doable in Mathematica? How?
- From: Paul Abbott <paul at physics.uwa.edu.au>
- Date: Thu, 6 Mar 2003 02:34:57 -0500 (EST)
- Organization: The University of Western Australia
- References: <b3v7ef$k96$1@smc.vnet.net>
- Sender: owner-wri-mathgroup at wolfram.com
In article <b3v7ef$k96$1 at smc.vnet.net>, "Konrad Den Ende" <chamsterkonrad at bigfoot.com> 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? You can use Distribute (or Outer) to produce all possible A, B, C. Then you can use @@@ (Apply at level 1) to apply the Boolean operators: Transpose[Module[{tab=Distribute[Table[{False,True},{3}],List,List]}, Join[Transpose[tab],{And @@@ tab},{Implies[#1 || #2, #3] & @@@ tab}]]] Then use TableForm to display with headings: TableForm[%, TableHeadings -> {None, {A, B, C, A && B && C, Implies[A || B, C]}}] Cheers, Paul -- Paul Abbott Phone: +61 8 9380 2734 School of Physics, M013 Fax: +61 8 9380 1014 The University of Western Australia (CRICOS Provider No 00126G) 35 Stirling Highway Crawley WA 6009 mailto:paul at physics.uwa.edu.au AUSTRALIA http://physics.uwa.edu.au/~paul