Created
December 28, 2011 21:10
-
-
Save smosher/1529754 to your computer and use it in GitHub Desktop.
OCaml -- simple infix range op.
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 ( -- ) x y = | |
let step_y = match y > x with | |
| true -> ( fun n -> n - 1 ) | |
| false -> ( fun n -> n + 1 ) | |
in | |
let rec mklist x y ll = | |
if x == y then y::ll | |
else mklist x (step_y y) (y::ll) | |
in | |
mklist x y [];; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment