merkle/simple_tree.go
func simpleHashFromHashes(hashes [][]byte) []byte {
	// Recursive impl.
	switch len(hashes) {
	case 0:
		return nil
	case 1:
		return hashes[0]
	default:
		left := simpleHashFromHashes(hashes[:(len(hashes)+1)/2])
		right := simpleHashFromHashes(hashes[(len(hashes)+1)/2:])
		return SimpleHashFromTwoHashes(left, right)
	}
}
func simpleHashFromHashes(hashes [][]byte) []byte {
	// Recursive impl.
	switch len(hashes) {
	case 0:
		return nil
	case 1:
		return hashes[0]
	default:
		left := simpleHashFromHashes(hashes[:(len(hashes)+1)/2])
		right := simpleHashFromHashes(hashes[(len(hashes)+1)/2:])
		return SimpleHashFromTwoHashes(left, right)
	}
}
func simpleHashFromHashes ( hashes [ ] [ ] byte ) [ ] byte { // Recursive impl. switch len ( hashes ) { case 0 : return nil case 1 : return hashes [ 0 ] default : left := simpleHashFromHashes ( hashes [ : ( len ( hashes ) + 1 ) / 2 ] ) right := simpleHashFromHashes ( hashes [ ( len ( hashes ) + 1 ) / 2 : ] ) return SimpleHashFromTwoHashes ( left , right ) } }
//----------------------------------------------------------------
// Expects hashes!
---------------------------------------------------------------- Expects hashes!