100-go-mistakes/12-optimizations/91-cpu-caches/predictability/main.go
2021-12-27 15:56:17 +01:00

23 lines
295 B
Go

package main
type node struct {
value int64
next *node
}
func linkedList(n *node) int64 {
var total int64
for n != nil {
total += n.value
n = n.next
}
return total
}
func sum2(s []int64) int64 {
var total int64
for i := 0; i < len(s); i += 2 {
total += s[i]
}
return total
}