Skip to content

Instantly share code, notes, and snippets.

@grapswiz
Created January 31, 2011 06:07
Show Gist options
  • Save grapswiz/803699 to your computer and use it in GitHub Desktop.
Save grapswiz/803699 to your computer and use it in GitHub Desktop.
(* 目的:x座標とy座標の組2つからその中点の座標の組を返す *)
(* float * float -> float * float -> float * float *)
let chuten point1 point2 = match point1 with
(x1, y1) -> (match point2 with
(x2, y2) -> ((x1 +. x2) /. 2.0, (y1 +. y2) /. 2.0))
let test1 = chuten (0.0, 0.0) (2.0, 2.0) = (1.0, 1.0)
let test2 = chuten (-3.0, -2.0) (4.0, 6.0) = (0.5, 2.0)
let test3 = chuten (-5.0, -3.0) (-4.0, -8.0) = (-4.5, -5.5)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment