Re: Something like Flatten

• To: mathgroup at smc.vnet.net
• Subject: [mg8619] Re: [mg8541] Something like Flatten
• From: Wouter Meeussen <w.meeussen.vdmcc at vandemoortele.be>
• Date: Fri, 12 Sep 1997 04:10:34 -0400
• Sender: owner-wri-mathgroup at wolfram.com

```hi all,

Something like Flatten?

if I look at a list (an expression) as having a depth profile:

_            _
\          /
\    /\  /
\  /  \/
\/

then Flatten does :

.            .
__          __
\    /\  /
\  /  \/
\/

and, further:

.            .
..          ..
___    __  ___
\  /  \/
\/

but, how can I obtain :

_            _
\          /
\    /\  /
\__/  \/
..

and, further:
_            _
\          /
\____/\__/
....  ..
..

a function like myFill[] to "fill in the throughs".
(* == throw earth into the deepest parts. *)

myFill[stuff_,up_:1]:=Map[Replace[#,{a_}:>
Sequence@@Flatten[{a},\[Infinity],List]]&,stuff,{up}]

for example.

it={1,{2},{{3}},{{{4}}},{{{{5}}}},{{{{{6}}}}},
q at 1,{q at 2},{{q at 3}},{{{q at 4}}},{{{{q at 5}}}}};

In[189]:=
Table[myFill[it,i],{i,6}]//ColumnForm
Out[189]=
{1, 2, 3, 4, 5, 6, q[1], q[2], q[3], q[4], q[5]}
{1, {2}, {3}, {4}, {5}, {6}, q[1], {q[2]}, {q[3]}, {q[4]}, {q[5]}}
{1, {2}, {{3}}, {{4}}, {{5}}, {{6}}, q[1], {q[2]}, {{q[3]}}, {{q[4]}}, {{q[5]}}}
{1, {2}, {{3}}, {{{4}}}, {{{5}}}, {{{6}}}, q[1], {q[2]}, {{q[3]}},
{{{q[4]}}}, {{{q[5]}}}}
{1, {2}, {{3}}, {{{4}}}, {{{{5}}}}, {{{{6}}}}, q[1], {q[2]}, {{q[3]}},
{{{q[4]}}}, {{{{q[5]}}}}}
{1, {2}, {{3}}, {{{4}}}, {{{{5}}}}, {{{{{6}}}}}, q[1], {q[2]}, {{q[3]}},
{{{q[4]}}}, {{{{q[5]}}}}}

there are some snags:

I would have prefered to make the second argument count the "sediment
layers" deposited in the throughs.
That's made difficult because Depth[] can't be used because it also includes
the q[..] and does not give a Depth of the List -heads exclusively.

anyone a better idea?

wouter.

>At 23:16 6-09-97 -0400, Hans Steffani wrote:
>>I have a list of list of (list of one number). How can I get a
>>list of list of numbers? Flatten does not work as the outer but
>>not the inner braces are deleted.
>>
>>Hans Friedrich Steffani
>>--
>>Hans Friedrich Steffani
>>Institut fuer Elektrische Maschinen und Antriebe, TU Chemnitz-Zwickau
>>mailto:hans.steffani at e-technik.tu-chemnitz.de
>>http://www.tu-chemnitz.de/~hfst/
>>
>>
>>
>>
>
>Dr. Wouter L. J. MEEUSSEN
>eu000949 at pophost.eunet.be
>w.meeussen.vdmcc at vandemoortele.be
>
>
>
>
>

NV Vandemoortele Coordination Center
Oils & Fats Applied Research
Prins Albertlaan 79
Postbus 40
B-8870 Izegem (Belgium)
Tel: +/32/51/33 21 11
Fax: +/32/51/33 21 75
vdmcc at vandemoortele.be

```

• Prev by Date: Re: Help with Iteration.
• Next by Date: Re: More: tantamount error messages when interupting
• Previous by thread: Re: Something like Flatten
• Next by thread: tantamount error messages when interupting