Skip to content

Instantly share code, notes, and snippets.

@danimal141
Last active October 10, 2016 08:47
Show Gist options
  • Save danimal141/65c2f5e2f1fb3cf3f1893c8e60402168 to your computer and use it in GitHub Desktop.
Save danimal141/65c2f5e2f1fb3cf3f1893c8e60402168 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 {
s := make([][]uint8, dy)
for i := range s {
s[i] = make([]uint8, dx)
}
for y := 0; y < dy; y++ {
for x := 0; x < dx; x++ {
s[y][x] = uint8((x * y))
}
}
return s
}
func main() {
pic.Show(Pic)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment