Last active
August 29, 2015 14:18
-
-
Save evandertino/d01d13665b7d7a210727 to your computer and use it in GitHub Desktop.
Go Exercise: Slices - http://tour.golang.org/moretypes/14
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 { | |
| slc := make([][]uint8, dy) | |
| for x := range slc { | |
| slc[x] = make([]uint8, dx) | |
| for y := range slc[x] { | |
| // Create equations below | |
| eq1 := (x + y) / 2 | |
| //eq2 := x * y | |
| //eq3 := x ^ y | |
| //eq4 := (x ^ y) * (x ^ y) | |
| slc[x][y] = uint8(eq1) | |
| } | |
| } | |
| return slc | |
| } | |
| func main() { | |
| pic.Show(Pic) | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment