Skip to content

Instantly share code, notes, and snippets.

View c-cube's full-sized avatar

Simon Cruanes c-cube

View GitHub Profile
@c-cube
c-cube / 1.ml
Last active August 29, 2015 14:15 — forked from kindlychung/1.ml
let rec take n l =
match n, l with
| 0, [] -> []
| _, [] -> raise (Invalid_argument "plop")
| _, h::t when n < 0 -> raise (Invalid_argument "drop")
| 0, _::_ -> []
| _, h::t -> h :: take (n - 1) t;;
take 2 [1; 2; 3; 4];;
take 2 [];;