MathGroup Archive 2010

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

Search the Archive

Re: Replacement Rule with Sqrt in denominator


> I don't want to claim that pattern matching in Mathematica is bugged,
> I am certainly not entitled to do so. I was always quite happy to
> follow the rules and look at the FullForm in order to create the
> correct pattern, until I learned (actually just by following this
> thread) that this does not always produce the expected results. So
> even though this may not be a bug, pattern matching can be very
> confusing sometimes, and, in terms of usability, may seem to be poorly
> implemented to some people.

> Having said that, could somebody give me a little insight on how
> pattern matching "really" works (I'm sure Daniel has done so many
> times already, please feel free to refer me to previous posts!):
> What set (or class) of expressions does pattern matching exclude from
> its "normal" behavior (obviously there is Rational, Complex,
> whatnot...)? Why? Are there different such classes? Why does 3/5[[1]]
> fail (alternatively: Why does Rational behave differently then List,
> say)?

I think the reason is that Rational, Complex, SparseArray and some
others are atoms, which you can check by AtomQ (see also
tutorial/BasicObjects). Unfortunately there seems to be no
"PatternMatcherForm" which would allow users to look at the expression
as the pattern matcher actually sees it. Also I can see no obvious and
consistent pattern on what is treated as an atom and what not: while
SparseArray-objects are atoms (tested with AtomQ and even documented as
such) InterpolatingFunction-objects are not...



  • Prev by Date: Re: Replacement Rule with Sqrt in denominator
  • Next by Date: Re: Solving matrix equations
  • Previous by thread: Re: Replacement Rule with Sqrt in denominator
  • Next by thread: Re: Replacement Rule with Sqrt in denominator