• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: SmartSet
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: SmartSet


  • Subject: Re: SmartSet
  • From: Luther Fuller <email@hidden>
  • Date: Wed, 18 Dec 2013 09:56:38 -0600

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!



 _______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users

This email sent to email@hidden

  • Follow-Ups:
    • Re: SmartSet
      • From: Alex Zavatone <email@hidden>
    • Re: SmartSet
      • From: Jon Pugh <email@hidden>
References: 
 >SmartSet (From: Shane Stanley <email@hidden>)

  • Prev by Date: Re: SmartSet
  • Next by Date: Re: SmartSet
  • Previous by thread: Re: SmartSet
  • Next by thread: Re: SmartSet
  • Index(es):
    • Date
    • Thread