-
Notifications
You must be signed in to change notification settings - Fork 0
/
union.go
38 lines (34 loc) · 1.09 KB
/
union.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
// package venn provides user with option to combine and join two or more datasets
// in to a unified unique data set
package venn
// UnionAll combines two input slices a1 and a2
// retains original data from input
func UnionAll(a1, a2 []interface{}) []interface{} {
r := make([]interface{}, 0, len(a1)+len(a2))
r = append(r, a1...)
r = append(r, a2...)
return r
}
// Union combines two different input slices a1 and a2
// provides unique result
func UnionString(a1, a2 []string) []string {
r := make([]string, 0, len(a1)+len(a2))
r = append(append(r, a1...), a2...)
return deDuplicateString(r)
}
// UnionInt combines two different input slices a1 and a2 of type int
// provides unique result
func UnionInt(a1, a2 []int) []int {
r := make([]int, 0, len(a1)+len(a2))
r = append(r, a1...)
r = append(r, a2...)
return deDuplicateint(r)
}
// UnionFloat64 combines two different slices a1 and a2 of type float64
// provides a unique result
func UnionFloat64(a1, a2 []float64) []float64 {
r := make([]float64, 0, len(a1)+len(a2))
r = append(r, a1...)
r = append(r, a2...)
return deDuplicatefloat64(r)
}