Skip to content

Instantly share code, notes, and snippets.

@mrfade
Created October 22, 2022 22:25
Show Gist options
  • Save mrfade/004e430c92f71fbee90e9a08880589a8 to your computer and use it in GitHub Desktop.
Save mrfade/004e430c92f71fbee90e9a08880589a8 to your computer and use it in GitHub Desktop.
A Tour of Go Exercise: Slices
package main
import (
"golang.org/x/tour/pic"
)
func Pic(dx, dy int) [][]uint8 {
xs := make([][]uint8, dy, dy)
for y := 0; y < dy; y++ {
xs[y] = make([]uint8, dx, dx)
for x := 0; x < dx; x++ {
xs[y][x] = uint8((x + y) / 2)
}
}
return xs
}
func main() {
pic.Show(Pic)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment