MathGroup Archive 2005

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

Search the Archive

Re: delete something from a complex list

  • To: mathgroup at smc.vnet.net
  • Subject: [mg58089] Re: delete something from a complex list
  • From: Jean-Marc Gulliet <jeanmarc.gulliet at gmail.com>
  • Date: Sat, 18 Jun 2005 06:07:41 -0400 (EDT)
  • Organization: The Open University, Milton Keynes, England
  • References: <d8u6sd$8mo$1@smc.vnet.net>
  • Sender: owner-wri-mathgroup at wolfram.com

mark wrote:
> hi
> how to delete numbers 1 and 2 from the multilevel nested list, while preserving the structure:
> {{{{1,3,2,4}},{{5,2}}},{{4,2},{6,1,7}}}
> i hope the result is:
> {{{{3,4}},{{5}}},{{4},{6,7}}}
> i have tried delete with no success but after i have flatten the list.
> thanks
>  
> 
Hi Mark,

You could try this:

In[1]:=
data = {{{{1, 3, 2, 4}}, {{5, 2}}}, {{4, 2}, {6, 1, 7}}}

Out[1]=
{{{{1, 3, 2, 4}}, {{5, 2}}}, {{4, 2}, {6, 1, 7}}}

In[2]:=
Position[data, (X_)?(#1 == 1 || #1 == 2 & )]

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

In[3]:=
Delete[data, %]

Out[3]=
{{{{3, 4}}, {{5}}}, {{4}, {6, 7}}}

Hope this helps,
/J.M.


  • Prev by Date: Re: delete something from a complex list
  • Next by Date: Re: Transformation rule problem
  • Previous by thread: Re: delete something from a complex list
  • Next by thread: Re: Zero Padding and ColumnAlignments in Version 5.1