Created
June 17, 2018 21:41
-
-
Save zonggen/1657c1210c99f70ada6b9a5a64b20abb to your computer and use it in GitHub Desktop.
A Tour of Go - Slices Exercise Answer
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 "golang.org/x/tour/pic" | |
func Pic(dx, dy int) [][]uint8 { | |
s_out := make ([][]uint8, dy) | |
for index1 := range s_out { | |
s_in := make ([]uint8, dx) | |
for index2 := range s_in { | |
s_in[index2] = uint8 (index1 ^ index2) | |
} | |
s_out[index1] = s_in | |
} | |
return s_out | |
} | |
func main() { | |
pic.Show(Pic) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment