home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1993 #1 / NN_1993_1.iso / spool / sci / math / symbolic / 3358 < prev    next >
Encoding:
Internet Message Format  |  1993-01-04  |  1.6 KB

  1. Path: sparky!uunet!news.claremont.edu!ucivax!news.service.uci.edu!beckman.com!dn66!a_rubin
  2. Newsgroups: sci.math.symbolic
  3. Subject: Re: all intersections of a list of sets
  4. Message-ID: <a_rubin.726177491@dn66>
  5. From: a_rubin@dsg4.dse.beckman.com (Arthur Rubin)
  6. Date: 4 Jan 93 19:58:11 GMT
  7. References: <C03MqH.DGA@news.cso.uiuc.edu>
  8. Organization: Beckman Instruments, Inc.
  9. Nntp-Posting-Host: dn66.dse.beckman.com
  10. Lines: 31
  11.  
  12. In <C03MqH.DGA@news.cso.uiuc.edu> Richard J. Gaylord <gaylord@ux1.cso.uiuc.edu> writes:
  13.  
  14. >ulf wostner asked me how to return all of the intersections of a list of
  15. >sets.
  16.  
  17. >eg., 
  18.  
  19. >AllIntersections[{{a,b,c},{b,c,d},{c,d,e}}]
  20. >{{c}, {b, c}, {c, d}, {a, b, c}, {b, c, d}, {c, d, e}}
  21.  
  22. >he and i are surprised that Outer[Intersection, sets, sets] doesn't work
  23. >at all {in fact, i can't figure out what its doing or why}.
  24.  
  25. >anyway, i made up a nested anonymous function kind of thing to do it. 
  26.  
  27. >AllIntersections[set_] :=
  28. >Union[Flatten[Map[(Map[Function[y, Intersection[#,y]], set])&,set], 1]] 
  29.  
  30. >AllIntersections[{{a,b,c},{b,c,d},{c,d,e}}]
  31. >{{c}, {b, c}, {c, d}, {a, b, c}, {b, c, d}, {c, d, e}}
  32.  
  33. AllIntersections[set_] :=
  34. List @@ Union[Flatten[Outer[Intersection,list$ @@ set,list$ @@ set]]]
  35.  
  36. Outer[f,ax,bx] doesn't work the way I would expect if any head of a member
  37. of ax is the same as the head of ax.
  38. --
  39. Arthur L. Rubin: a_rubin@dsg4.dse.beckman.com (work) Beckman Instruments/Brea
  40. 216-5888@mcimail.com 70707.453@compuserve.com arthur@pnet01.cts.com (personal)
  41. My opinions are my own, and do not represent those of my employer.
  42. My interaction with our news system is unstable; please mail anything important.
  43.