Skip to content

Instantly share code, notes, and snippets.

@fjpse
Created May 15, 2020 16:41
Show Gist options
  • Save fjpse/ff99238b89f043e6df39dc69d029f614 to your computer and use it in GitHub Desktop.
Save fjpse/ff99238b89f043e6df39dc69d029f614 to your computer and use it in GitHub Desktop.
-module(lst).
-export([
take/2,
]).
%%
%% take(N, L) -> returns the N first elements of the list L
%%
take(0, _L) -> [];
take(_N, []) -> [];
take(N, [X|Xs]) when is_integer(N) andalso N > 0 ->
[X | take(N-1, Xs)].
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment