spudly.shuoink.com

the best way to predict the future is to implement it

Entries Comments


Array.union();

31 May, 2008 (15:36) | JavaScript | No comments

Here’s another set theory prototype for the Array object in JavaScript. This one performs a union of the two arrays.
Usage;
var setA = [ 1, 2, 3, 4, 5, 6 ];
var setB = [ 4, 5, 6, 7, 8 ];
var union = setA.union( setB ); // Now union is [ 1, 2, 3, 4, 5, 6, [...]

Array.intersection()

31 May, 2008 (14:48) | JavaScript | 1 comment

I’m sure a lot of you know what set theory is if you’re reading a programming blog. Anyway, a big part of set theory is the concept of an intersection between two sets of data. This is essentially the parts of the sets that the two have in common. Here’s an prototype for the intersection [...]