Created
November 30, 2016 06:45
-
-
Save tnightingale/3083ee4d18ccb85d714db21f1a37f39c to your computer and use it in GitHub Desktop.
This file contains 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
// 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