Created
December 29, 2013 13:02
-
-
Save marcesher/8170295 to your computer and use it in GitHub Desktop.
simple solution to Go tour slide 35, exercise on slices. This prints a blue gradient
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" | |
"math" | |
) | |
func Pic(dx, dy int) [][]uint8 { | |
p := make([][] uint8, dy) | |
for i :=0; i < dy; i++ { | |
p[i] = make([] uint8, dx) | |
} | |
for i :=0; i < dy; i++ { | |
for z :=0; z < dx; z++ { | |
p[i][z] = uint8(math.Nextafter(float64(i), float64(z))) | |
} | |
} | |
return p | |
} | |
func main() { | |
pic.Show(Pic) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment