Permalink
Browse files

add arrays.union

  • Loading branch information...
1 parent 4abc65a commit d044fcf724e3f06e98b2f7445306f05e7e128caf @dominictarr committed Nov 18, 2011
Showing with 14 additions and 1 deletion.
  1. +14 −1 arrays.js
View
@@ -65,5 +65,18 @@ module.exports = {
strictLast: strictLast,
strictHead: strictHead,
empty: empty,
- flatten: flatten
+ flatten: flatten,
+ union: union
+}
+
+function union (a, b) {
+
+ var c = []
+ function add (item) {
+ if(!~c.indexOf(item))
+ c.push(item)
+ }
+ a.forEach(add)
+ b.forEach(add)
+ return c
}

0 comments on commit d044fcf

Please sign in to comment.