Created
May 24, 2010 13:40
-
-
Save manveru/411874 to your computer and use it in GitHub Desktop.
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 "math" | |
type Point struct { | |
x int | |
y int | |
} | |
func (p0 Point) distanceTo(p1 Point) float64{ | |
return math.Sqrt(float64((p0.x-p1.x)*(p0.x-p1.x) + (p0.y-p1.y)*(p0.y-p1.y))) | |
} | |
func main() { | |
p0 := Point{10, 10} | |
p1 := Point{20, 20} | |
p0.distanceTo(p1) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment