MathGroup Archive 2005

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

Search the Archive

Re: delete something from a complex list


On Jun 17, 2005, at 5:20 AM, 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
>
>

In[1]:=
lst = {{{{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]:=
Delete[lst, Join[Position[
     lst, 1], Position[lst,
     2]]]
Out[2]=
{{{{3, 4}}, {{5}}},
   {{4}, {6, 7}}}

János


--------------------------------------------
f @@ # & /@ ===  f @@@


  • Prev by Date: Re: delete something from a complex list
  • Next by Date: Re: delete something from a complex list
  • Previous by thread: Re: delete something from a complex list
  • Next by thread: Re: delete something from a complex list