Re: Re: Re: Select in Math.
- To: mathgroup at smc.vnet.net
- Subject: [mg18663] Re: [mg18532] Re: [mg16518] Re: Select in Math.
- From: kewjoi at hixnet.co.za (Kew Joinery)
- Date: Thu, 15 Jul 1999 01:45:50 -0400
- References: <ef280f77.24b8f8da@aol.com>
- Sender: owner-wri-mathgroup at wolfram.com
There is a dispute between two professors and both sides asked me to be a witness, so I will reproduce my original massage. Up to me (I'm only 17) the most seemly code I received was from Andrzej Kozlowski and Jurgen Tischer: Select[Level[list,{-2}],OrderedQ] BobHanlon at aol.com wrote: > 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 Arnold Knopfmacher wrote: > Bob > > As I understand Eugene's question (perhaps he can confirm this for us), > if given the list > list={{1,4,3,2},{1,3,2,4},{2,3},{5},{6,8}}; > the desired output would be {{2,3},{5},{6,8}} since these are the sublists > whose elements are in increasing order. Your solution outputs > {{5},{6,8},{1,2,3,4}} > which would then be incorrect if my interpretation of the question is right. > Arnold > > Arnold Knopfmacher > Deputy Director: > Centre for Applicable Analysis and Number Theory > Witwatersrand University > Johannesburg 2050 > South Africa > http://sunsite.wits.ac.za/wits/science/number_theory/arnold.htm > Fax: 2711-4039317 > Phone: 2711- 7163353 > email: arnoldk at gauss.cam.wits.ac.za On Tue, Mar 9, 1999, Kew Joinery <kewjoi at hixnet.co.za> wrote: >Hello, >My name is Eugene(16 years old) and I ask you small help, please. >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.