A Bug in Flatten?
- To: mathgroup@smc.vnet.net
- Subject: [mg11111] A Bug in Flatten?
- From: Ersek_Ted%PAX1A@mr.nawcad.navy.mil
- Date: Sun, 22 Feb 1998 14:55:36 -0500
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