MathGroup Archive 2012

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

Search the Archive

Pattern Syntax for Alternate Heads with Default Value


I'm trying to build a unary function which accepts only arguments with
two possible heads and has a default value.  That is, something like
the following, except that this doesn't work.  Anyone know how to do
this correctly?

f[(x_Real | x_Integer) : 2.5] := x^2;
where f[3] = 9
and f[1.5] = 2.25
and f[] = 6.25





  • Prev by Date: Re: recursively solve equation and save the values only
  • Next by Date: How to get the corresponding coefficients?
  • Previous by thread: Mathematica loop
  • Next by thread: Re: Pattern Syntax for Alternate Heads with Default Value