Skip to content

Instantly share code, notes, and snippets.

@joyeecheung
Created January 7, 2015 04:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save joyeecheung/bacc5ff91b11b1283c99 to your computer and use it in GitHub Desktop.
Save joyeecheung/bacc5ff91b11b1283c99 to your computer and use it in GitHub Desktop.
Reverse a sequence(array or string) recursively.
function reverse(seq) {
if (seq.length > 1)
return seq.slice(-1).concat(reverse(seq.slice(0, -1)));
else
return seq;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment