Services & Resources / Wolfram Forums
-----
 /
MathGroup Archive
1999
*January
*February
*March
*April
*May
*June
*July
*August
*September
*October
*November
*December
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

MathGroup Archive 1999

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

Search the Archive

RE: ? Repeated Patterns ?

  • To: mathgroup at smc.vnet.net
  • Subject: [mg18876] RE: [mg18858] ? Repeated Patterns ?
  • From: "Ersek, Ted R" <ErsekTR at navair.navy.mil>
  • Date: Sun, 25 Jul 1999 03:30:11 -0400
  • Sender: owner-wri-mathgroup at wolfram.com

DongGook Park  asked about some confusing use of repeated patterns.
-------------------------

The following Mathematica result quite confuses me. I can understand the
output of
the first input command, but not the second output. Why not {0,1) but
{0,0,0,1}?


In[1]:=
{1,0,0,0} /. {x___Integer, y_Integer..} -> {x, y}

Out[1]=
{1,0}

In[2]:=
{0,0,0,1} /. {x_Integer.., y___Integer} -> {x, y}

Out[2]=
{0,0,0,1}

--------------------
I might be wrong if I tried to justify the above.  Anyway I think it's much
more instructive if you can tell which part of the output is (x) and which
part is (y).

Below I give some interesting variations of your examples.


In[3]:=
{1,0,0,0}/.{x___Integer,y_Integer..}->{{x},{y}}
Out[3]=
{{1},{0}}


In[4]:=
{1,0,0,0}/.{x__Integer,y_Integer..}->{{x},{y}}
Out[4]=
{{1},{0}}


In[5]:=
{0,0,0,1}/.{x_Integer..,y___Integer}->{{x},{y}}
Out[5]=
{{0},{0,0,1}}


In[6]:=
{0,0,0,1}/.{x_Integer...,y___Integer}->{{x},{y}}
Out[6]=
{{},{0,0,0,1}}


In[7]:=
{1,0,0,0} /. {x___Integer, y:(_Integer..)} -> {{x},{ y}}
Out[7]=
{{},{1,0,0,0}}


In[8]:=
{1,0,0,0} /. {x__Integer, y:(_Integer..)} -> {{x},{ y}}
Out[8]=
{{1},{0,0,0}}


In[9]:=
{0,0,0,1} /. {x:(_Integer..), y___Integer} -> {{x},{ y}}
Out[9]=
{{0},{0,0,1}}


In[10]:=
{0,0,0,1} /. {x:(_Integer...), y___Integer} -> {{x},{ y}}
Out[10]=
{{},{0,0,0,1}}


-----------------
Regards,
Ted Ersek


  • Prev by Date: RE: Numeric Cache Clear
  • Next by Date: TeXSave and User Defined Style Sheets
  • Previous by thread: Re: ? Repeated Patterns ?
  • Next by thread: Slow Mathematica front end