Skip to content

Instantly share code, notes, and snippets.

@kamatama41
Created August 27, 2014 05:47
Show Gist options
  • Save kamatama41/1b9dc76f62581f3c9056 to your computer and use it in GitHub Desktop.
Save kamatama41/1b9dc76f62581f3c9056 to your computer and use it in GitHub Desktop.
My answer of "a tour of Go #36( http://go-tour-jp.appspot.com/#36 )"
package main
import (
"math"
"code.google.com/p/go-tour/pic"
)
func Pic(dx, dy int) [][]uint8 {
result := make([][]uint8, dx)
for x := 0; x < dx; x++ {
innerSlice := make([]uint8, dy)
for y := 0; y < dy; y++ {
// x^y
innerSlice[y] = uint8(math.Pow(float64(x), float64(y)))
// (x+y)/2
// innerSlice[y] = uint8((x + y)/ 2)
// x * y
// innerSlice[y] = uint8(x * y)
}
result[x] = innerSlice
}
return result
}
func main() {
pic.Show(Pic)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment