Skip to content

Instantly share code, notes, and snippets.

@tnightingale
Created November 30, 2016 06:45
Show Gist options
  • Save tnightingale/3083ee4d18ccb85d714db21f1a37f39c to your computer and use it in GitHub Desktop.
Save tnightingale/3083ee4d18ccb85d714db21f1a37f39c to your computer and use it in GitHub Desktop.
// let rec reverse p1 p2 =
// match p1 with
// [] -> p2
// | n :: p1’ -> reverse p1’ (n :: p2)
function reverse(p1, p2=[]) {
if (!p1.length) {
return p2;
}
const [n, ..._p1] = p1;
return reverse(_p1, [n, ...p2]);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment