summaryrefslogtreecommitdiffstats
path: root/cmd/jp/split.go
blob: efe59c9b7957487b8cd06fd49ef080023b204945 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
package main

import "reflect"

func flatten(in [][]reflect.Value) (out []reflect.Value) {
	for _, a := range in {
		for i := range a {
			out = append(out, a[i])
		}
	}
	return
}

func split(in [][]reflect.Value) (x, y []reflect.Value) {
	flat := flatten(in)
	n := len(flat)
	x = flat[:n/2]
	y = flat[n/2:]
	return
}