spudly.shuoink.com

the best way to predict the future is to implement it

Entries Comments


Array.complement();

31 May, 2008 (16:51) | JavaScript | No comments

Heres a method to get the relative complement of one array to another. Thus, it will return an array of everything that is in the current array but not in the array you pass in.
Usage:
var setA = [ 1, 2, 3 ];
var setB = [ 3, 4, 5 ];
var setC = setA.complement( setB ); // [...]

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 [...]