Skip to content

Instantly share code, notes, and snippets.

@jchung05
Created September 25, 2018 00:38
Show Gist options
  • Save jchung05/8b61b9207198f1acd454bfa6af9ff5e3 to your computer and use it in GitHub Desktop.
Save jchung05/8b61b9207198f1acd454bfa6af9ff5e3 to your computer and use it in GitHub Desktop.
An attempt at the A Tour of Go Slices exercise
package main
import "golang.org/x/tour/pic"
func Pic(dx, dy int) [][]uint8 {
arr := make([][]uint8, dy)
for i := range arr {
arr[i] = make([]uint8, dx)
for j:= range arr[i] {
arr[i][j] = uint8((i + j) / 2)
}
}
return arr
}
func main() {
pic.Show(Pic)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment