Last active
October 10, 2016 08:47
-
-
Save danimal141/65c2f5e2f1fb3cf3f1893c8e60402168 to your computer and use it in GitHub Desktop.
A Tour of Go Exercise: Slices
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 "golang.org/x/tour/pic" | |
func Pic(dx, dy int) [][]uint8 { | |
s := make([][]uint8, dy) | |
for i := range s { | |
s[i] = make([]uint8, dx) | |
} | |
for y := 0; y < dy; y++ { | |
for x := 0; x < dx; x++ { | |
s[y][x] = uint8((x * y)) | |
} | |
} | |
return s | |
} | |
func main() { | |
pic.Show(Pic) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment