Created
December 26, 2014 02:47
-
-
Save rndD/1a7baee8bf0144758cea to your computer and use it in GitHub Desktop.
Go lang Exercise: Slices
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 "code.google.com/p/go-tour/pic" | |
func Pic(dx, dy int) [][]uint8 { | |
slice := make([][]uint8, dy) | |
for iy := range slice { | |
slice[iy] = make([]uint8, dx) | |
for ix := range slice { | |
slice[iy][ix] = uint8((ix * iy) - (ix * ix)) | |
} | |
} | |
return slice | |
} | |
func main() { | |
pic.Show(Pic) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment