Skip to content

Instantly share code, notes, and snippets.

View Medeah's full-sized avatar

Frederik Andersen Medeah

  • The Restaurant at the End of the Universe
  • 13:37 (UTC +02:00)
View GitHub Profile
@Medeah
Medeah / gist:5127581
Created March 10, 2013 08:07
A Tour of Go 35: Exercise: Slices
package main
import "code.google.com/p/go-tour/pic"
func Pic(dx, dy int) [][]uint8 {
slicePic := make([][]uint8, dy)
for y := range slicePic {
slicePic[y] = make([]uint8, dx)
for x := range slicePic[y] {
slicePic[y][x] = uint8(x ^ y)
@Medeah
Medeah / gist:5127545
Created March 10, 2013 07:50
A Tour of Go 23: Exercise: Loops and Functions
package main
import (
"fmt"
"math"
)
// square root function using Newton's method
func Sqrt(x float64) float64 {
z := 1.0