Skip to content

Instantly share code, notes, and snippets.

@meltedice
Created October 2, 2017 04:55
Show Gist options
  • Save meltedice/5748b34a5c947d80621abfee98ee953c to your computer and use it in GitHub Desktop.
Save meltedice/5748b34a5c947d80621abfee98ee953c to your computer and use it in GitHub Desktop.
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, _ := range pic {
pic[y] = make([]uint8, dx)
for x, _ := range pic[y] {
pic[y][x] = uint8(x*y)
}
}
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