Create a gist now

Instantly share code, notes, and snippets.

A Tour of Go: Exercise Slices, https://go-tour-jp.appspot.com/moretypes/18
package main
import "golang.org/x/tour/pic"
func Pic(dx, dy int) [][]uint8 {
pic := make([][]uint8, dy)
for y := 0; y < dy; y++ {
pic[y] = make([]uint8, dx)
for x := 0; x < dx; x++ {
pic[y][x] = (uint8)(y+x) / 2
}
}
return pic
}
func main() {
pic.Show(Pic)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment