Prev: priorities between @, @@ and //
Next: 0/1 knapsack-like minimalization problem and file system access
From: Bill Rowe on 31 Mar 2010 06:26 On 3/30/10 at 5:01 AM, sagittarius5962(a)gmail.com (nt) wrote: >Is there a way to build an if statement with two conditions such as: >if[a>b and a>0,...]. If there is, could you let me know the syntax? Either If[a>b && a>0, ...] or If[And[a>b, a>0, ...] will do what you want
From: dr DanW on 31 Mar 2010 06:27 You almost had it. If[ And[ a>b, a>0], ...] There are a number of ways to write it If[ (a>b)~And~(a>0), ...], If[ (a>b) && (a>0), ...] Most people like the last one. Daniel
From: Murray Eisenberg on 31 Mar 2010 06:27 Did you at all attempt to use the documentation to answer your question? If not, you might begin by using the search field in the Documentation Center to look up each of: if and Actually, unless you're a complete novice at Mathematica, you'd already know that the names of built-in objects always begin with an upper-case letter, so you'd save some time sifting through lists of references by looking up instead each of: If And On 3/30/2010 6:01 AM, nt wrote: > Hi all, > > Is there a way to build an if statement with two conditions such as: > if[a>b and a>0,...]. If there is, could you let me know the syntax? > > Thanks > nt > -- Murray Eisenberg murray(a)math.umass.edu Mathematics & Statistics Dept. Lederle Graduate Research Tower phone 413 549-1020 (H) University of Massachusetts 413 545-2859 (W) 710 North Pleasant Street fax 413 545-1801 Amherst, MA 01003-9305
From: Manfred Plagmann on 1 Apr 2010 06:58 Logical operators are && for AND and || for OR etc. Just string your logic together: If[a>b && a>0, ...] The documentation is your friend and will list all logical operators.
First
|
Prev
|
Pages: 1 2 Prev: priorities between @, @@ and // Next: 0/1 knapsack-like minimalization problem and file system access |