Last active
October 14, 2016 07:25
-
-
Save fliptheweb/d23144d2354dcc9bbcc6b13ab5044a2e to your computer and use it in GitHub Desktop.
Classic Haskell quicksort to js es6 implementation with destructuring and rest/spread operator
This file contains hidden or 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
| quickSort = ([x, ...xs]) => { | |
| if (typeof(x) === 'undefined') return []; | |
| return [ | |
| ...quickSort(xs.filter(y => y <= x)), | |
| x, | |
| ...quickSort(xs.filter(y => y > x)) | |
| ]; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment