Re: Problem with Which

• To: mathgroup at smc.vnet.net
• Subject: [mg74158] Re: [mg74040] Problem with Which
• From: Bob Hanlon <hanlonr at cox.net>
• Date: Tue, 13 Mar 2007 03:35:40 -0500 (EST)

```I cannot duplicate the problem on my system; however, I recommend that you use Module to isolate tipo to be a local variable. A module would also enable you to use a shorthand notation for NumericQ

AH[Ts_,Th_,Tr_,f_,w_,i_]:=
Module[{tipo,n=NumericQ},
Which[
n[Ts]&&n[Th],tipo=1,
n[Ts]&&n[Tr],tipo=2,
n[Ts]&&n[f],tipo=3,
n[Ts]&&n[w],tipo=4,
n[Ts]&&n[i],tipo=5,
n[Th]&&n[Tr],tipo=6,
n[Th]&&n[f],tipo=7,
n[Th]&&n[w],tipo=8,
n[Th]&&n[i],tipo=9,
n[Tr]&&n[f],tipo=10,
n[Tr]&&n[w],tipo=11,
n[Tr]&&n[i],tipo=12,
n[f]&&n[w],tipo=13,
n[f]&&n[i],tipo=14,
n[w]&&n[i],tipo=15];
tipo];

AH[1,Th,Tr,f,4,i]

4

AH[1,Th,Tr,f,w,5]

5

AH[Ts,Th,Tr,4,4,i]

13

AH[Ts,Th,Tr,4,w,5]

14

Bob Hanlon

---- Miguel <mibelair at hotmail.com> wrote:
> Let a function of six variable
> AH[Ts_,Th_,Tr_,f_,w_,i_]:=(
>     Which[NumericQ[Ts]&&NumericQ[Th],tipo=1,
>       NumericQ[Ts]&&NumericQ[Tr],tipo=2,
>       NumericQ[Ts]&&NumericQ[f],tipo=3,
>       NumericQ[Ts]&&NumericQ[w],tipo=4,
>       NumericQ[Ts]&&NumericQ[i],tipo=5,
>       NumericQ[Th]&&NumericQ[Tr],tipo=6,
>       NumericQ[Th]&&NumericQ[f],tipo=7,
>       NumericQ[Th]&&NumericQ[w],tipo=8,
>       NumericQ[Th]&&NumericQ[i],tipo=9,
>       NumericQ[Tr]&&NumericQ[f],tipo=10,
>       NumericQ[Tr]&&NumericQ[w],tipo=11,
>       NumericQ[Tr]&&NumericQ[i],tipo=12,
>       NumericQ[f]&&NumericQ[w],tipo=13,
>       NumericQ[f]&&NumericQ[i],tipo=14,
>       NumericQ[w]&&NumericQ[i],tipo=15];
> tipo)
>
> In[77]:=AH[1,Th,Tr,f,4,i]
> Out[77]=
> 4
> Correct
>
> In[78]:=AH[1,Th,Tr,f,w,5]
> Out[78]=
> 4
> Wrong
>
> In[79]:=AH[Ts,Th,Tr,4,4,i]
> Out[79]=
> 13
> Correct
>
> In[80]:=AH[Ts,Th,Tr,4,w,5]
> Out[80]=
> 13
> Wrong
>
> I d'ont understand. Where is my error?

```

• Prev by Date: Re: Re: Multi-core Support in Mathematica 5.2
• Next by Date: NDSolve and Systems of DEs
• Previous by thread: Re: Problem with Which
• Next by thread: Re: Problem with Which