Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.soft-sys.math.mathematica > #11179 > unrolled thread
| Started by | Bob Hanlon <hanlonr357@gmail.com> |
|---|---|
| First post | 2012-08-02 08:58 +0000 |
| Last post | 2012-08-02 08:58 +0000 |
| Articles | 1 — 1 participant |
Back to article view | Back to comp.soft-sys.math.mathematica
This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by
below is the oldest one visible, not the original post.
Re: Evaluation of boolean functions in Mathematica 8 Bob Hanlon <hanlonr357@gmail.com> - 2012-08-02 08:58 +0000
| From | Bob Hanlon <hanlonr357@gmail.com> |
|---|---|
| Date | 2012-08-02 08:58 +0000 |
| Subject | Re: Evaluation of boolean functions in Mathematica 8 |
| Message-ID | <jvdfev$c5p$1@smc.vnet.net> |
There are a number of ways.
Clear[g, p, q, r]
First, note the form of your g
g = BooleanConvert[And[p, q, r], "BFF"]
BooleanFunction[<3>][p,q,r]
You need to use or substitute for the existing arguments not add
additional arguments
Method 1: Replace (Drop and Add)
g[[0]][True, True, True]
True
g[[0]] @@@ Tuples[{True, False}, 3]
{True, False, False, False, False, False, False, False}
Method 2: Replace (Substitute)
g /. {p -> True, q -> True, r -> True}
True
(g /. Thread[{p, q, r} -> #]) & /@
Tuples[{True, False}, 3]
{True, False, False, False, False, False, False, False}
Method 3: Set the existing arguments
p = True; q = True; r = True;
g
True
Or locally rather than globally
Clear[p, q, r]
With[{p = True, q = True, r = True}, Evaluate[g]]
True
Bob Hanlon
On Wed, Aug 1, 2012 at 4:55 AM, <lalwani.akhil@gmail.com> wrote:
> Hello,
>
> I want to evaluate a Boolean function by substituting True and False values for its variables, to get a True or False value at the output. Example,
>
> g = BooleanConvert[And[p, q, r], "BFF"]
>
> g[True,True,True]
>
> But the above statement does not evaluate g at the data-point given, but instead returns the statement,
>
> BooleanFunction[<3>][p,q,r][True,True,True]
>
> Can anybody please suggest how to proceed?
>
> Thanks a lot.
>
Back to top | Article view | comp.soft-sys.math.mathematica
csiph-web