Re: how implement sets
- To: mathgroup at smc.vnet.net
- Subject: [mg41515] Re: how implement sets
- From: Bobby Treat <drmajorbob+MathGroup3528 at mailblocks.com>
- Date: Sat, 24 May 2003 01:03:14 -0400 (EDT)
- Sender: owner-wri-mathgroup at wolfram.com
Have a look at http://library.wolfram.com/infocenter/BySubject/Mathematics/Foundations/SetTheory/ Bobby -----Original Message----- From: Murray Eisenberg <murraye at attbi.com> To: mathgroup at smc.vnet.net Subject: [mg41515] how implement sets Mathematica has no built-in data type for sets in the mathematical sense (no implied order of elements). This is to ask your advice in how in Mathematica to implement sets, for use in teaching math, where the distinction between an "ordered set" and just a plain "set" is crucial. Inherently, lists in Mathematica have an order, so List itself certainly cannot be the correct thing to use. Here are two possibilities: (1) A set is a list with no repeated parts. Then a function SetQ is needed to test that. Obvious definition: SetQ[x_] := ListQ[x] && Length[Union[x]] == Length[x] (2) Create a new "datatype" by using an appropriately-named head, such as -- WHAT? Mathematica has already appropriated the word Set for something else, of course. Perhaps Class or Collection? (And then overload Union, Intersection, Complement so they do what they should with such objects.) Any thoughts on which might be preferable, or on some other way? -- Murray Eisenberg murray at math.umass.edu Mathematics & Statistics Dept. Lederle Graduate Research Tower phone 413 549-1020 (H) University of Massachusetts 413 545-2859 (W) 710 North Pleasant Street fax 413 545-1801 Amherst, MA 01003-9305