Skip to content

Commit

Permalink
cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
drhodes committed Apr 23, 2010
1 parent 2cbdde4 commit bfff4cb
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 0 deletions.
12 changes: 12 additions & 0 deletions README.md
Expand Up @@ -22,3 +22,15 @@ A Set data type with the following methods.
fromList (to instantiate from a list)
toList (to makes a list)


example:

var set1 = new Set()
var set2 = new Set()
set1.add(1).add(2).add(3)
set2.add(3).add(4).add(5)

set1.union(set2) => Set<1, 2, 3, 4, 5>
set1.intersection(set2) => Set<3>

see tests.js for more examples
8 changes: 8 additions & 0 deletions set.js
Expand Up @@ -4,7 +4,15 @@
* under the terms of either the MIT License or the GNU General Public License (GPL) Version 2.
*
example:
var set1 = new Set()
var set2 = new Set()
set1.add(1).add(2).add(3)
set2.add(3).add(4).add(5)
set1.union(set2) => Set<1, 2, 3, 4, 5>
set1.intersection(set2) => Set<3>
see tests.js for more examples;
+ add
+ clear
Expand Down
7 changes: 7 additions & 0 deletions tests.js
Expand Up @@ -174,6 +174,13 @@ assert.ok(!s1.isSuperset(s2));

var temp = s2.union(s1);

var set1 = new Set()
var set2 = new Set()
set1.add(1).add(2).add(3)
set2.add(3).add(4).add(5)

sys.puts(set1.union(set2));
sys.puts(set1.intersection(set2));

sys.puts(s2.union(s3).add(4));
sys.puts("All passed.");

0 comments on commit bfff4cb

Please sign in to comment.