INNER CODE UNIT · Go

firstPeriodIfRepeated

stacklok/toolhive · cmd/help/dedupe-enums/main.go:93

func firstPeriodIfRepeated(lines []string) ([]string, bool) {
	n := len(lines)
	if n < 2 {
		return nil, false
	}
	for period := 1; period <= n/2; period++ {
		if n%period != 0 {
			continue
		}
		repeated := true
		for i := period; i < n; i++ {
			if lines[i] != lines[i-period] {
				repeated = false
				break
			}
		}
		if repeated {
			return lines[:period], true

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…