Re: Filtering a list of list for certain elements that are neighbours
- To: mathgroup at smc.vnet.net
- Subject: [mg88840] Re: [mg88834] Filtering a list of list for certain elements that are neighbours
- From: Curtis Osterhoudt <cfo at lanl.gov>
- Date: Mon, 19 May 2008 05:14:59 -0400 (EDT)
- Organization: LANL
- References: <200805181134.HAA23914@smc.vnet.net>
- Reply-to: cfo at lanl.gov
Here's another possibility, which might give more flexibility (not sure). I couldn't figure out how to combine the "or" statements inside one Cases argument -- any clues? In[1011]:= Cases[Cases[mylist, Except[{___, a, b, ___}]], Except[{___, b, a, ___}]] Out[1011]= {{a, c, b}, {b, c, a}} Cheers, C.O. On Sunday 18 May 2008 05:34:18 Steven Siew wrote: > I have a list of lists > > mylist={{a,b,c},{a,c,b},{b,a,c},{b,c,a},{c,a,b},{c,b,a}} > > I want to filter out all lists that have "a being a neighbor to b". > > I am looking for the following result. > > {{a,c,b},{b,c,a}} > > > For this toy example, I can probably do it by hand but my real problem > has 120 lists in a list. And I need to filter out various combination > of letters like "s cannot be next to d" , "s cannot be next to j" , "c > cannot be next to j" , "h cannot be next to d" and "h cannot be next > to s". -- ========================================================== Curtis Osterhoudt cfo at remove_this.lanl.and_this.gov PGP Key ID: 0x4DCA2A10 Please avoid sending me Word or PowerPoint attachments See http://www.gnu.org/philosophy/no-word-attachments.html ==========================================================
- References:
- Filtering a list of list for certain elements that are neighbours
- From: Steven Siew <stevensiew2@gmail.com>
- Filtering a list of list for certain elements that are neighbours