Skip to content

Instantly share code, notes, and snippets.

@inhies
Created August 5, 2017 01:38
Show Gist options
  • Save inhies/e450aad78984fc4cd9f6681cdcbbe94a to your computer and use it in GitHub Desktop.
Save inhies/e450aad78984fc4cd9f6681cdcbbe94a to your computer and use it in GitHub Desktop.
Create pairings only once https://play.golang.org/p/UFOP4OTm7r
package main
import (
"fmt"
"os"
)
func main() {
a := []int{1, 2, 3, 4, 5}
for len(a) > 0 {
for i := 1; i < len(a); i++ {
fmt.Fprintln(os.Stderr, a[0], a[i])
}
a = append(a[:0], a[1:]...)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment