Nesting / Repetitive Functions
- To: mathgroup at smc.vnet.net
- Subject: [mg36073] Nesting / Repetitive Functions
- From: "Ashraf El Ansary" <Elansary at btopenworld.com>
- Date: Thu, 15 Aug 2002 02:36:26 -0400 (EDT)
- Sender: owner-wri-mathgroup at wolfram.com
Dear All,
I was wondering if there was any method besides the Nest[] function to
repeat function more than once during the same Input/Output cycle ..
Actually what I'm trying to reach is as follows:
Defining X= ToString[HoldForm[Cat"Basic Algebra" None TM"Expand"
TM"Factor" ]];
Defining U=Part[Flatten[StringPosition[X,"
"]],Range[1,Length[Flatten[StringPosition[X," "]]],2]]
That's giving the location of Blank spaces within X.
Then
One=StringDrop[X,{U[[1]],U[[1]]}];
Two[i_]:=StringDrop[%,{U[[i+1]]-i,U[[i+1]]-i}];
I'm Trying to apply
In[32]:=
One
Out[32]=
CatBasic Algebra None TM Expand TM Factor
In[33]:=
Two[1]
Out[33]=
CatBasicAlgebra None TM Expand TM Factor
In[34]:=
Two[2]
Out[34]=
CatBasicAlgebraNone TM Expand TM Factor
In[35]:=
Two[3]
Out[35]=
CatBasicAlgebraNoneTM Expand TM Factor
In[36]:=
Two[4]
Out[36]=
CatBasicAlgebraNoneTMExpand TM Factor
------------------
It is not just that I'd like to remove the blanks but rather interested in
the idea.. I tried to build a loop but % didn't work since % doesn't work
unless the result of the whole loop is out, I know I can use Nest[] but
don't know how to do it... Any suggestions.... Thanks.
I know I might have a silly answer.. I just had Mathematica for less than a
couple of weeks... Thanks You ALL