|
[Date Index]
[Thread Index]
[Author Index]
Re: Using a logical Or in the function definition
- To: mathgroup at smc.vnet.net
- Subject: [mg86730] Re: Using a logical Or in the function definition
- From: Jens-Peer Kuska <kuska at informatik.uni-leipzig.de>
- Date: Wed, 19 Mar 2008 05:27:53 -0500 (EST)
- Organization: Uni Leipzig
- References: <fro39q$i8a$1@smc.vnet.net>
- Reply-to: kuska at informatik.uni-leipzig.de
Hi,
ab[r_,s_]/; (IntegerQ[r]|| Head[r]===Rational) && (IntegerQ[s]||
Head[s]===Rational):=r/s
??
and all variants of patterns, i.e.,
ab[r_Integer,s_Integer]:=r/s
ab[r_Rational,s_Integer]:=r/s
ab[r_Integer,s_Rational]:=r/s
ab[r_Rational,s_Rational]:=r/s
Regards
Jens
ahallam at iastate.edu wrote:
> I would like to use Or in the function definition as in
>
> ab[ Or[r_Integer,r_Rational], Or[s_Integer,s_Rational] ]:=r/s;
>
> In other words, I want the function to take integers or ratios of
> integers as arguments, but not real numbers which are not rational.
>
> But if I give the function integer arguments, it does not evaluate.
>
> If I try
>
> ar[ r_Integer , Or[s_Integer , s_Rational]] := r/s;
>
> and give an integer first argument it works and so on.
>
Prev by Date:
Re: Using a logical Or in the function definition
Next by Date:
Re: Unwanted lined in PDF-exported Graphics3D
Previous by thread:
Re: Using a logical Or in the function definition
Next by thread:
Re: Using a logical Or in the function definition
|