Re: if with two conditions
- To: mathgroup at smc.vnet.net
- Subject: [mg108769] Re: if with two conditions
- From: Bob Hanlon <hanlonr at cox.net>
- Date: Wed, 31 Mar 2010 05:25:21 -0500 (EST)
f[x_, y_] := If[x > y && Mod[x, 2] == 0, 1, 0] g[x_, y_] := If[And[x > y, Mod[x, 2] == 0], 1, 0] mat = Table[{x, y}, {x, 0, 4}, {y, 0, 4}]; Apply[f, mat, {2}] {{0, 0, 0, 0, 0}, {0, 0, 0, 0, 0}, {1, 1, 0, 0, 0}, {0, 0, 0, 0, 0}, {1, 1, 1, 1, 0}} % == Apply[g, mat, {2}] True Bob Hanlon ---- nt <sagittarius5962 at gmail.com> 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