Skip to content

Instantly share code, notes, and snippets.

@Pygmalion69
Created February 28, 2020 14:27
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 Pygmalion69/b4790ba5765c7860814480d9e258d280 to your computer and use it in GitHub Desktop.
Save Pygmalion69/b4790ba5765c7860814480d9e258d280 to your computer and use it in GitHub Desktop.
A Tour of Go - Exercise: Slices
// https://tour.golang.org/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)/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