Re: Problem with Which

• To: mathgroup at smc.vnet.net
• Subject: [mg74211] Re: Problem with Which
• From: "Ray Koopman" <koopman at sfu.ca>
• Date: Wed, 14 Mar 2007 03:54:22 -0500 (EST)
• References: <eslsiq\$q3v\$1@smc.vnet.net>

```Miguel 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?

Why not define

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

Then, if you really need a variable named "tipo" to hold the value,
you can say  tipo = AH[...].  Otherwise, simply use  AH[...].

```

• Prev by Date: Re: NDSolve. Getting the final values
• Next by Date: Re: Integrate
• Previous by thread: Re: Problem with Which
• Next by thread: Re: "Transparency" with respect to differentiation