MCPcopy
hub / github.com/google/go-cmp / zigzag

Function zigzag

cmp/internal/diff/diff.go:397–402  ·  view source on GitHub ↗

zigzag maps a consecutive sequence of integers to a zig-zag sequence. [0 1 2 3 4 5 ...] => [0 -1 +1 -2 +2 ...]

(x int)

Source from the content-addressed store, hash-verified

395//
396// [0 1 2 3 4 5 ...] => [0 -1 +1 -2 +2 ...]
397func zigzag(x int) int {
398 if x&1 != 0 {
399 x = ^x
400 }
401 return x >> 1
402}

Callers 1

DifferenceFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected