Skip to content

Instantly share code, notes, and snippets.

@spudtrooper
Created September 7, 2022 08:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save spudtrooper/f6519c7d1ad19b124e53f90558d400ea to your computer and use it in GitHub Desktop.
Save spudtrooper/f6519c7d1ad19b124e53f90558d400ea to your computer and use it in GitHub Desktop.

Kudos to github copilot!

I wrote this:

// Verify that for each indiividual midi state, the states with notes on form a dense cluster.
for _, ms := range o.States {

And copilot suggested this:

// Verify that for each indiividual midi state, the states with notes on form a dense cluster.
for _, ms := range o.States {
	// Get the slots with notes on.
	var slots []int
	for _, ts := range ms.TackStates {
		if len(ts.Notes) > 0 {
			slots = append(slots, ts.Slot)
		}
	}
	// Verify that the slots form a dense cluster.
	if len(slots) > 0 {
		sort.Ints(slots)
		for i := 0; i < len(slots)-1; i++ {
			if slots[i+1]-slots[i] != 1 {
				return fmt.Errorf("slots not dense: %s", goutiljson.MustColorMarshal(ms))
			}
		}
	}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment