Skip to content

Instantly share code, notes, and snippets.

@ccorcos

ccorcos/reason3.re

Created Mar 28, 2017
Embed
What would you like to do?
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
You can’t perform that action at this time.