I am a mathematician with a specialty in topology and set theory and a few comments on set theory seem appropriate here.
On Dec 18, 2013, at 6:25 AM, Shane Stanley wrote: One of the useful classes in Cocoa (and other languages) is the set,
The class 'set' in a computer language may be useful, but it has very little to do with 'set theory' in mathematics. which is like a list except each item can only appear once. Sets are not normally ordered like lists, but Cocoa also has ordered lists, which maintain their order.
A common list of axioms for set theory is called 'ZFC' where the 'C' is the "Axiom of Choice". The "Axiom of Choice" states that every set can be indexed, that is, it can be written as an ordered list. This means that you can use lists as sets without any problems.
But there are problems with trying to implement 'sets' in a computer language. The statement "x â y" ("x is an element of y") does not mean what you probably think it means. It can be translated as: x is a set which is used in the construction of y. Notice that y may not be a set. Y is a class, however. (Mathematicians meaning of "class") Notice that this also means that if {a, b, c} is a set, then a is a set and b is a set and c is a set. (Because, you can only construct sets from sets.)
The empty set is always denoted by 0 (the zero character). (Using the "slash-zero" symbol went out decades ago.) Written in curly-bracket notation: 0 = {}. In set theory, the integers are modeled by n+1 = n ⪠{n} (n union {n}) which can be AppleScripted â¦
my numberAsSet(5) log the result
on numberAsSet(n) set nextSet to {} -- the empty set repeat n times set nextSet to (nextSet & {nextSet}) end repeat return nextSet -- a list construction of the integer n end numberAsSet -----------
You can have hours of fun with this!
|