Travis build: 425

This commit is contained in:
Travis CI
2017-12-28 11:44:44 +00:00
parent 9709b16536
commit 13b740c4b6
4 changed files with 63 additions and 5 deletions

View File

@ -249,6 +249,15 @@
</details> </details>
### _Uncategorized_
<details>
<summary>View contents</summary>
* [`quickSort`](#quicksort)
</details>
## Adapter ## Adapter
### call ### call
@ -4002,6 +4011,33 @@ validateNumber('10'); // true
[⬆ Back to top](#table-of-contents) [⬆ Back to top](#table-of-contents)
## _Uncategorized_
### quickSort
QuickSort an Array (ascending sort by default).
Use recursion.
Use `Array.filter` and spread operator (`...`) to create an array that all elements with values less than the pivot come before the pivot, and all elements with values greater than the pivot come after it.
If the parameter `desc` is truthy, return array sorts in descending order.
```js
const quickSort = ([n, ...nums], desc) =>
isNaN(n)
? []
: [
...quickSort(nums.filter(v => (desc ? v > n : v <= n)), desc),
n,
...quickSort(nums.filter(v => (!desc ? v > n : v <= n)), desc)
];
```
```js
quickSort([4, 1, 3, 2]); // [1,2,3,4]
quickSort([4, 1, 3, 2], true); // [4,3,2,1]
```
[⬆ back to top](#table-of-contents)
## Credits ## Credits

View File

@ -262,6 +262,9 @@
<a class="sublink-1" href="#uuidgenerator">UUIDGenerator</a> <a class="sublink-1" href="#uuidgenerator">UUIDGenerator</a>
<a class="sublink-1" href="#validatenumber">validateNumber</a> <a class="sublink-1" href="#validatenumber">validateNumber</a>
<h3>Uncategorized
</h3><a class="sublink-1" href="#quicksort">quickSort</a>
</nav><main class="col-sm-12 col-md-8 col-lg-9" style="height:100%;overflow-y:auto;background:#eceef2;padding:0"><a id="top">&nbsp;</a><h2 style="text-align:center">Adapter</h2> </nav><main class="col-sm-12 col-md-8 col-lg-9" style="height:100%;overflow-y:auto;background:#eceef2;padding:0"><a id="top">&nbsp;</a><h2 style="text-align:center">Adapter</h2>
<div class="card fluid"><div class="section double-padded"><h3 id="call">call</h3></div><div class="section double-padded"> <div class="card fluid"><div class="section double-padded"><h3 id="call">call</h3></div><div class="section double-padded">
<p>Given a key and a set of arguments, call them when given a context. Primarily useful in composition.</p> <p>Given a key and a set of arguments, call them when given a context. Primarily useful in composition.</p>
@ -1776,6 +1779,24 @@ Use <code>Number()</code> to check if the coercion holds.</p>
</code></pre> </code></pre>
<pre><code class="language-js">validateNumber('10'); // true <pre><code class="language-js">validateNumber('10'); // true
</code></pre> </code></pre>
</div></div><br/><h2 style="text-align:center">Uncategorized</h2>
<div class="card fluid"><div class="section double-padded"><h3 id="quicksort">quickSort</h3></div><div class="section double-padded">
<p>QuickSort an Array (ascending sort by default).</p>
<p>Use recursion.
Use <code>Array.filter</code> and spread operator (<code>...</code>) to create an array that all elements with values less than the pivot come before the pivot, and all elements with values greater than the pivot come after it.
If the parameter <code>desc</code> is truthy, return array sorts in descending order.</p>
<pre><code class="language-js">const quickSort = ([n, ...nums], desc) =&gt;
isNaN(n)
? []
: [
...quickSort(nums.filter(v =&gt; (desc ? v &gt; n : v &lt;= n)), desc),
n,
...quickSort(nums.filter(v =&gt; (!desc ? v &gt; n : v &lt;= n)), desc)
];
</code></pre>
<pre><code class="language-js">quickSort([4, 1, 3, 2]); // [1,2,3,4]
quickSort([4, 1, 3, 2], true); // [4,3,2,1]
</code></pre>
</div></div><br/> </div></div><br/>
<footer> <footer>
<p style="display:inline-block"><strong>30 seconds of code</strong> is licensed under the <a href="https://github.com/Chalarangelo/30-seconds-of-code/blob/master/LICENSE">CC0-1.0</a> license.<br/>Icons made by <a href="https://www.flaticon.com/authors/smashicons">Smashicons</a> from <a href="https://www.flaticon.com/">www.flaticon.com</a> is licensed by <a href="http://creativecommons.org/licenses/by/3.0/">CC 3.0 BY</a>.<br/>Ribbon made by <a href="https://github.com/tholman/github-corners">Tim Holman</a> is licensed by <a href="https://opensource.org/licenses/MIT">The MIT License</a><br/>Built with the <a href="https://minicss.org">mini.css framework</a>.</p> <p style="display:inline-block"><strong>30 seconds of code</strong> is licensed under the <a href="https://github.com/Chalarangelo/30-seconds-of-code/blob/master/LICENSE">CC0-1.0</a> license.<br/>Icons made by <a href="https://www.flaticon.com/authors/smashicons">Smashicons</a> from <a href="https://www.flaticon.com/">www.flaticon.com</a> is licensed by <a href="http://creativecommons.org/licenses/by/3.0/">CC 3.0 BY</a>.<br/>Ribbon made by <a href="https://github.com/tholman/github-corners">Tim Holman</a> is licensed by <a href="https://opensource.org/licenses/MIT">The MIT License</a><br/>Built with the <a href="https://minicss.org">mini.css framework</a>.</p>

View File

@ -11,13 +11,13 @@ const quickSort = ([n, ...nums], desc) =>
isNaN(n) isNaN(n)
? [] ? []
: [ : [
...quickSort(nums.filter(v => desc ? v > n : v <= n), desc), ...quickSort(nums.filter(v => (desc ? v > n : v <= n)), desc),
n, n,
...quickSort(nums.filter(v =>!desc ? v > n : v <= n), desc) ...quickSort(nums.filter(v => (!desc ? v > n : v <= n)), desc)
] ];
``` ```
```js ```js
quickSort([4,1,3,2,]); // [1,2,3,4] quickSort([4, 1, 3, 2]); // [1,2,3,4]
quickSort([4,1,3,2,],true); // [4,3,2,1] quickSort([4, 1, 3, 2], true); // [4,3,2,1]
``` ```

View File

@ -94,6 +94,7 @@ promisify:adapter
pull:array pull:array
pullAtIndex:array pullAtIndex:array
pullAtValue:array pullAtValue:array
quickSort:uncategorized
randomHexColorCode:utility randomHexColorCode:utility
randomIntegerInRange:math randomIntegerInRange:math
randomNumberInRange:math randomNumberInRange:math