MathGroup Archive 2011

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

Search the Archive

Re: pattern example

  • To: mathgroup at smc.vnet.net
  • Subject: [mg119824] Re: pattern example
  • From: Bill Rowe <readnews at sbcglobal.net>
  • Date: Fri, 24 Jun 2011 07:45:48 -0400 (EDT)

On 6/23/11 at 7:25 AM, fgutiers2002 at yahoo.com (Francisco Gutierrez)
wrote:

>I find in Leonid's (Shiffrin) excellent book the following example
>(p. 122): f[3/5,4,5,2/3]/.f[x:(_Integer|_Rational)..]:>{x}

>According to the book, this returns {3/5,4,5,2/3}

>However, I get (Mathematica 8.0.1, Windows 7) f[3/5,4,5,2/3]

>What's wrong? Francisco

Perhaps it is platform dependent since I see:

In[1]:= f[3/5, 4, 5, 2/3] /. f[x : (_Integer | _Rational) ..] :> {x}

Out[1]= {3/5, 4, 5, 2/3}

In[2]:= $Version

Out[2]= 8.0 for Mac OS X x86 (64-bit) (February 23, 2011)

But isn't it simpler to use the functional construct?

In[3]:= List @@ f[3/5, 4, 5, 2/3]

Out[3]= {3/5, 4, 5, 2/3}



  • Prev by Date: Re: pattern example
  • Next by Date: Re: Assigning part of indexed object
  • Previous by thread: Re: pattern example
  • Next by thread: Re: pattern example