Last active
April 14, 2016 17:04
-
-
Save Minoru/c4e6fd1c010027060cf046a0db7ead48 to your computer and use it in GitHub Desktop.
OCamlin' along with @rexim
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
let on f g = fun x y -> f (g x) (g y) | |
(* uncurry from https://thelema.github.io/batteries-included/hdoc/BatPervasives.html | |
dunno if you can use that *) | |
(* line 15 can't be rewritten like that. | |
I'm still trying to come up with another solution, but it's really different from the other two *) | |
(* line 16 *) | |
List.map (fun (vx, vy) -> atan2 (float_of_int vy) (float_of_int vx)) | |
(* ...turns into... *) | |
List.map (uncurry (on atan2 float_of_int)) | |
(* line 19 *) | |
List.sort (fun (_, a1) (_, a2) -> compare a1 a2) | |
(* ...turns into... *) | |
List.sort (uncurry (on compare snd)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment