Services & Resources / Wolfram Forums / MathGroup Archive
-----

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: [mg86711] Re: Using a logical Or in the function definition
  • From: giovanni resta <g.restaCUT at CUTiit.cnr.it>
  • Date: Wed, 19 Mar 2008 05:24:18 -0500 (EST)
  • References: <fro39q$i8a$1@smc.vnet.net>

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.

Probably I do not understand your problem,
but every Integer is also Rational, so
you can use something like
ab[r_/;Element[r,Rationals], s_/;Element[s,Rationals]] := r/s;

instead of Element[r,Rationals] you can type
  r [Esc]el[Esc] Rationals
where [Esc] is the Esc key.

g.


g.


  • Prev by Date: Re: Using a logical Or in the function definition
  • Next by Date: Re: Using a logical Or in the function definition
  • Previous by thread: Re: Using a logical Or in the function definition
  • Next by thread: Re: Using a logical Or in the function definition