Where is a good mathematical sets implementation for JavaScript? It should include efficient implementations of intersection, union, complement, and (for bonus points) the Carte
I personally like how it is done in jPaq (http://jpaq.org/documentation/Arrays+as+Sets/1.0/). Here are three examples that I tested out successfully:
alert([1,2,3,4,5].subtract([2,3,5])); // evaluates to [1,4]
alert([1,2,5].union([1,3,4,5])); // evaluates to [1,2,5,3,4]
alert([1,2,3,5].intersect([0,1,2,4,6])); // evaluates to [1,2]
The nice thing about jPaq is the fact that you can just download the code for these three functions. jPaq makes it so you don't have to download the extra stuff that you will not be using anyway.