Re: Using a logical Or in the function definition
- To: mathgroup at smc.vnet.net
- Subject: [mg86717] Re: Using a logical Or in the function definition
- From: Albert Retey <awnl at arcor.net>
- Date: Wed, 19 Mar 2008 05:25:27 -0500 (EST)
- References: <fro39q$i8a$1@smc.vnet.net>
Hi, > ab[ Or[r_Integer,r_Rational], Or[s_Integer,s_Rational] ]:=r/s; When constructing Patterns, you need to use Alternatives, not Or, which serves a different purpose. I think ab[r:(_Integer|_Rational),s:(_Integer|_Rational)]:=r/s should do what you need (| is a shortcut for Alternatives). If this is unfamiliar to you, you might consider learning more about pattern matching in mathmatica. hth, albert