Skip to content

Instantly share code, notes, and snippets.

@guitarrapc
Created October 20, 2018 06:17
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 guitarrapc/18f7210e4b2295a1c8c41c5ff636bb62 to your computer and use it in GitHub Desktop.
Save guitarrapc/18f7210e4b2295a1c8c41c5ff636bb62 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 "code.google.com/p/go-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 )
//pic[y][x] = uint8( x*y )
//pic[y][x] = uint8( x^y )
//pic[y][x] = uint8( ((x^y) * (x^y)))
pic[y][x] = uint8( ((x*y) + (x*y))/(x^y + 1))
}
}
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