Created
August 27, 2014 05:47
-
-
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 )"
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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