Skip to content

Instantly share code, notes, and snippets.

@zonggen
Created June 17, 2018 21:41
Show Gist options
  • Save zonggen/1657c1210c99f70ada6b9a5a64b20abb to your computer and use it in GitHub Desktop.
Save zonggen/1657c1210c99f70ada6b9a5a64b20abb to your computer and use it in GitHub Desktop.
A Tour of Go - Slices Exercise Answer
package main
import "golang.org/x/tour/pic"
func Pic(dx, dy int) [][]uint8 {
s_out := make ([][]uint8, dy)
for index1 := range s_out {
s_in := make ([]uint8, dx)
for index2 := range s_in {
s_in[index2] = uint8 (index1 ^ index2)
}
s_out[index1] = s_in
}
return s_out
}
func main() {
pic.Show(Pic)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment