MathGroup Archive 2010

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

Search the Archive

Re: Building clusters out of a nested list

  • To: mathgroup at smc.vnet.net
  • Subject: [mg114969] Re: Building clusters out of a nested list
  • From: Bob Hanlon <hanlonr at cox.net>
  • Date: Fri, 24 Dec 2010 04:13:57 -0500 (EST)
  • Reply-to: hanlonr at cox.net

Using capital letters will conflict with built-in names (e.g., E).

{{a, b, c}, {c, d}, {e, f}, {f, h}} //.
 {s___, t1 : {___, x_, ___}, 
   m___, t2 : {___, x_, ___}, e___} :>
  {s, Union[t1, t2], m, e}

{{a, b, c, d}, {e, f, h}}


Bob Hanlon

---- Dmitry <dpesin at gmail.com> wrote: 

=============
Dear All,

please, help me find a solution to the following problem:

suppose I have a list of the form { {A,B,C},{C,D},{E,F},{F,H}}. I need
to build a list whose entries are unions of all entries of the
original list with nonzero intersection. For the example above, the
end result is {{A,B,C,D},{E,F,H}}.

Thanks a lot!



  • Prev by Date: Re: Building clusters out of a nested list
  • Next by Date: Re: bibtex support in Mathematica 8
  • Previous by thread: Re: Building clusters out of a nested list
  • Next by thread: Re: Building clusters out of a nested list