MathGroup Archive 2008

[Date Index] [Thread Index] [Author Index]

Search the Archive

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


  • Prev by Date: Re: FindRoot solving of Excel input columns
  • Next by Date: N::meprec warning with Solve
  • Previous by thread: Re: Using a logical Or in the function definition
  • Next by thread: Re: Using a logical Or in the function definition