Mathematica 9 is now available
Services & Resources / Wolfram Forums
-----
 /
MathGroup Archive
1998
*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 1998

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

Search the Archive

A Bug in Flatten?




Hi
This is Ted Ersek

I got the info on Flatten, and wanted to see what I can do when I give
it a  third argument.

In[1]:=
Remove[f,g];
?Flatten

"Flatten[list] flattens out nested lists.  Flatten[list, n] flattens to 
level \
n. Flatten[list, n, h] flattens subexpressions with head h."

 -------------------------------------- Examples:
In this case it looks like Flatten removed the two outer layers of (f)
In[2]:=
s1=g[f[f[f[1],f[2]],f[f[3],f[4]]]];
Flatten[s1,2,f]

Out[2]=
g[f[1],f[2],f[3],f[4]]

In this case all layers of (f) are removed. In[3]:=
Flatten[s1,Infinity,f]

Out[3]=
g[1,2,3,4]


In the next examples (f) doesn't appear until the third level. Now
Flatten doesn't see (f) at all.  Should layers of (f) get removed in 
these examples?
In[4]:=
s2=g[g[f[f[f[1],f[2]],f[f[3],f[4]]]]]; Flatten[s2,3,f]

Out[4]=
g[g[f[f[f[1],f[2]],f[f[3],f[4]]]]]

In[5]:=
Flatten[s2,Infinity,f]

Out[5]=
g[g[f[f[f[1],f[2]],f[f[3],f[4]]]]]


Ted Ersek




  • Prev by Date: Re: [TS 3549]--Re[TS 2350]:font problems printing notebooks under 3.0
  • Next by Date: Differential Equation evaluation
  • Prev by thread: Re: [TS 3549]--Re[TS 2350]:font problems printing notebooks under 3.0
  • Next by thread: Re: A Bug in Flatten?