MathGroup Archive 2004

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

Search the Archive

Optional Alternatives

  • To: mathgroup at
  • Subject: [mg50010] Optional Alternatives
  • From: Selwyn Hollis <sh2.7183 at>
  • Date: Wed, 11 Aug 2004 05:53:08 -0400 (EDT)
  • References: <>
  • Sender: owner-wri-mathgroup at

Is it possible to require a function argument to match alternative 
patterns and be optional at the same time? As a toy example, suppose I 

    f[x:_Real|_Rational]:= x

Is there a way make the argument optional with a given default value, 
say 0? I've tried this:

    f[Optional[x:_Real|_Rational, 0]]:= x

and various other combinations with no success. (Of course I could do 
this: f[]:= 0, but I'm interested in the more general issue.)

Selwyn Hollis
(edit reply-to to reply)

  • References:
  • Prev by Date: message 50001?
  • Next by Date: Re: Problem with FourierTransform
  • Previous by thread: 50,000th Message
  • Next by thread: Re: Optional Alternatives