Created
August 28, 2013 18:40
-
-
Save flc/6369657 to your computer and use it in GitHub Desktop.
A Tour of Go - Exercise: Slices
http://tour.golang.org/#36
This file contains hidden or 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 "code.google.com/p/go-tour/pic" | |
func Pic(dx, dy int) [][]uint8 { | |
img_func := func(x, y int) uint8 { | |
//return uint8(x*y) | |
//return uint8((x+y) / 2) | |
return uint8(x^y) | |
} | |
img := make([][]uint8, dy) | |
for i := range(img) { | |
img[i] = make([]uint8, dx) | |
for j := range(img[i]) { | |
img[i][j] = img_func(i, j) | |
} | |
} | |
return img | |
} | |
func main() { | |
pic.Show(Pic) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment