Created
March 28, 2017 17:50
-
-
Save ccorcos/6e3d1b9c7ad3b00de2af9dc5f697b4cf to your computer and use it in GitHub Desktop.
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 rec firstN n l => | |
switch (n, l) { | |
| (0, _) => [] | |
| (_, []) => [] | |
| (n, [h, ...t]) => [h, ...firstN (n - 1) t] | |
}; | |
firstN 2 [1, 2, 3, 4, 5]; /* => list int: [1, 2] */ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment