Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.soft-sys.math.mathematica > #3276

Re: pattern example

From Bill Rowe <readnews@sbcglobal.net>
Newsgroups comp.soft-sys.math.mathematica
Subject Re: pattern example
Date 2011-06-24 11:49 +0000
Organization Steven M. Christensen and Associates, Inc and MathTensor, Inc.
Message-ID <iu1tka$9jl$1@smc.vnet.net> (permalink)

Show all headers | View raw


On 6/23/11 at 7:25 AM, fgutiers2002@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}

Back to comp.soft-sys.math.mathematica | Previous | Next | Find similar | Unroll thread


Thread

Re: pattern example Bill Rowe <readnews@sbcglobal.net> - 2011-06-24 11:49 +0000

csiph-web