Last active
August 29, 2015 14:04
-
-
Save ShigekiKarita/be25933b1debb185a3c2 to your computer and use it in GitHub Desktop.
JavaScriptのリスト内包表記が括弧悪い
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
// for firefox31 | |
const quicksort = (array) => | |
{ | |
if (array.length == 0) return []; | |
const head = array[0]; | |
const rest = array.slice(1); | |
const small = [i for each (i in rest) if (head >= i)]; //rest.filter(a => head >= a); | |
const large = [i for each (i in rest) if (head < i)]; //rest.filter(a => head < a); | |
return [].concat(quicksort(small), head, quicksort(large)); | |
}; | |
quicksort([2,5,3,2,-1]); // Array [ -1, 2, 2, 3, 5 ] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment