Created
July 6, 2017 07:46
-
-
Save Ceroce/ff3aa039c7ee1ce66b6e66e1cfc878c9 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
-module (take). | |
-export ([take/2]). | |
% Take the first N elements of a list. | |
% N may be larger than the length of the list, in which case the whole list is returned. | |
-spec take(integer(),[T]) -> [T]. | |
take(0, _) -> []; | |
take(_,[]) -> []; | |
take(N,[X|Xs]) -> [X|take(N-1, Xs)]. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment