Skip to content

Instantly share code, notes, and snippets.

@smosher
Created December 28, 2011 21:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save smosher/1529754 to your computer and use it in GitHub Desktop.
Save smosher/1529754 to your computer and use it in GitHub Desktop.
OCaml -- simple infix range op.
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