Skip to content

Instantly share code, notes, and snippets.

@leostera
Last active August 29, 2015 13:56
Show Gist options
  • Save leostera/8817193 to your computer and use it in GitHub Desktop.
Save leostera/8817193 to your computer and use it in GitHub Desktop.
% Chapter 5: Hello Recursion!
% Subtitle: A sublist function
tail_sublist(L, N) -> tail_sublist(L, N, []).
tail_sublist(_, 0, SubList) -> SubList;
tail_sublist([], _, SubList) -> SubList;
tail_sublist([H|T], N, SubList) when N > 0 ->
tail_sublist(T, N-1, [H|SubList]).
% shouldn't this be
% tail_sublist(T, N-1, Sublist++[H]). ?
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment