MathGroup Archive 1999

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

Search the Archive

Re: Re: Re: Select in Math.

  • To: mathgroup at smc.vnet.net
  • Subject: [mg18595] Re: [mg18532] Re: [mg16518] Re: Select in Math.
  • From: BobHanlon at aol.com
  • Date: Tue, 13 Jul 1999 01:01:27 -0400
  • Sender: owner-wri-mathgroup at wolfram.com

Arnold,

As best as I can interpret the original question, I do not understand your 
result.  However, without a definition of the problem with more clarity than 
the one example, I can't say one way or the other.  

Perhaps, Eugene (kewjoi at hixnet.co.za) can clarify what the desired output 
should be.

Bob Hanlon

In a message dated 7/9/99 4:57:32 AM, arnoldk at gauss.cam.wits.ac.za writes:

>Regarding your solution on extracting increasing sublists:
>
>[mg16518]. Consider
>
>In[42]:=
>list={{1,4,3,2},{1,3,2,4},{2,3},{5},{6,8}};
>
>In[43]:=
>list=Union[Sort /@ list]
>
>Out[43]=
>{{5},{2,3},{6,8},{1,2,3,4}}
>
>In[44]:=
>elts=Union[Flatten[%]]
>
>Out[44]=
>{1,2,3,4,5,6,8}
>
>In[45]:=
>incrlist=Select[list,Union[Flatten[Complement[list,{#}]]]!=elts&]
>
>Out[45]=
>{{5},{6,8},{1,2,3,4}}
>
>However, the correct output should be  {{5},{2,3},{6,8}}.
>

Original messages:

In a message dated 3/8/99 6:43:38 PM, kewjoi at hixnet.co.za writes:

>My question is how can I extract (select) list of lists in increasing
>order?
>For example:
>In[2]:=list={{{1,2,3,4},{1,2,4,3}},{{2,3,1},{5}},{6,7}}
>Out[2]={{{1,2,3,4},{1,2,4,3}},{{2,3,1},{5}},{6,7}}
>
>I 'd like to obtain only the parts in increased order, therefore the
>result should be :
>Out[3]={{1,2,3,4},{5},{6,7}}
>I did try (Cases, Select, and Extract) but definitely not in proper way.
>

Eugene,

This may be what you want.

list={{{1,2,3,4},{1,2,4,3}},{{2,3,1},{5}},{6,7}};

The nesting of the lists does not appear to be pertinent to your problem, 
so simplify the structure by eliminating the nesting.  Also, Sort sublists 
and eliminate duplicates:

list = Union[Sort /@ {list //. 
					{x__List} -> Sequence[x]}]

{{5}, {6, 7}, {1, 2, 3}, {1, 2, 3, 4}}

Eliminate subsets

elements = Union[Flatten[list]];

list = Select[list, Not[Union[Flatten[
					Complement[list, {#}]]] == elements]&]

{{5}, {6, 7}, {1, 2, 3, 4}}

Sort by first element

Sort[list, First[#1] < First[#2]&]

{{1, 2, 3, 4}, {5}, {6, 7}}


Bob Hanlon



  • Prev by Date: LaTex for publication
  • Next by Date: Re: Manipulating differential equations
  • Previous by thread: Re: Re: Select in Math.
  • Next by thread: Re: Re: Re: Select in Math.