home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!news.claremont.edu!ucivax!news.service.uci.edu!beckman.com!dn66!a_rubin
- Newsgroups: sci.math.symbolic
- Subject: Re: all intersections of a list of sets
- Message-ID: <a_rubin.726177491@dn66>
- From: a_rubin@dsg4.dse.beckman.com (Arthur Rubin)
- Date: 4 Jan 93 19:58:11 GMT
- References: <C03MqH.DGA@news.cso.uiuc.edu>
- Organization: Beckman Instruments, Inc.
- Nntp-Posting-Host: dn66.dse.beckman.com
- Lines: 31
-
- In <C03MqH.DGA@news.cso.uiuc.edu> Richard J. Gaylord <gaylord@ux1.cso.uiuc.edu> writes:
-
- >ulf wostner asked me how to return all of the intersections of a list of
- >sets.
-
- >eg.,
-
- >AllIntersections[{{a,b,c},{b,c,d},{c,d,e}}]
- >{{c}, {b, c}, {c, d}, {a, b, c}, {b, c, d}, {c, d, e}}
-
- >he and i are surprised that Outer[Intersection, sets, sets] doesn't work
- >at all {in fact, i can't figure out what its doing or why}.
-
- >anyway, i made up a nested anonymous function kind of thing to do it.
-
- >AllIntersections[set_] :=
- >Union[Flatten[Map[(Map[Function[y, Intersection[#,y]], set])&,set], 1]]
-
- >AllIntersections[{{a,b,c},{b,c,d},{c,d,e}}]
- >{{c}, {b, c}, {c, d}, {a, b, c}, {b, c, d}, {c, d, e}}
-
- AllIntersections[set_] :=
- List @@ Union[Flatten[Outer[Intersection,list$ @@ set,list$ @@ set]]]
-
- Outer[f,ax,bx] doesn't work the way I would expect if any head of a member
- of ax is the same as the head of ax.
- --
- Arthur L. Rubin: a_rubin@dsg4.dse.beckman.com (work) Beckman Instruments/Brea
- 216-5888@mcimail.com 70707.453@compuserve.com arthur@pnet01.cts.com (personal)
- My opinions are my own, and do not represent those of my employer.
- My interaction with our news system is unstable; please mail anything important.
-