Travis build: 427
This commit is contained in:
70
README.md
70
README.md
@ -63,6 +63,7 @@
|
||||
* [`pull`](#pull)
|
||||
* [`pullAtIndex`](#pullatindex)
|
||||
* [`pullAtValue`](#pullatvalue)
|
||||
* [`quickSort`](#quicksort)
|
||||
* [`remove`](#remove)
|
||||
* [`sample`](#sample)
|
||||
* [`shuffle`](#shuffle)
|
||||
@ -249,15 +250,6 @@
|
||||
|
||||
</details>
|
||||
|
||||
### _Uncategorized_
|
||||
|
||||
<details>
|
||||
<summary>View contents</summary>
|
||||
|
||||
* [`quickSort`](#quicksort)
|
||||
|
||||
</details>
|
||||
|
||||
## Adapter
|
||||
|
||||
### call
|
||||
@ -1236,6 +1228,39 @@ console.log(pulled); // [ 'b', 'd' ]
|
||||
[⬆ Back to top](#table-of-contents)
|
||||
|
||||
|
||||
### 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)
|
||||
];
|
||||
```
|
||||
|
||||
<details>
|
||||
<summary>Examples</summary>
|
||||
|
||||
```js
|
||||
quickSort([4, 1, 3, 2]); // [1,2,3,4]
|
||||
quickSort([4, 1, 3, 2], true); // [4,3,2,1]
|
||||
```
|
||||
|
||||
</details>
|
||||
|
||||
|
||||
[⬆ Back to top](#table-of-contents)
|
||||
|
||||
|
||||
### remove
|
||||
|
||||
Removes elements from an array for which the given function returns `false`.
|
||||
@ -4011,33 +4036,6 @@ validateNumber('10'); // true
|
||||
|
||||
[⬆ 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
|
||||
|
||||
|
||||
@ -138,6 +138,7 @@
|
||||
<a class="sublink-1" href="#pull">pull</a>
|
||||
<a class="sublink-1" href="#pullatindex">pullAtIndex</a>
|
||||
<a class="sublink-1" href="#pullatvalue">pullAtValue</a>
|
||||
<a class="sublink-1" href="#quicksort">quickSort</a>
|
||||
<a class="sublink-1" href="#remove">remove</a>
|
||||
<a class="sublink-1" href="#sample">sample</a>
|
||||
<a class="sublink-1" href="#shuffle">shuffle</a>
|
||||
@ -262,9 +263,6 @@
|
||||
<a class="sublink-1" href="#uuidgenerator">UUIDGenerator</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"> </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">
|
||||
<p>Given a key and a set of arguments, call them when given a context. Primarily useful in composition.</p>
|
||||
@ -648,6 +646,23 @@ let pulled = pullAtValue(myArray, ['b', 'd']);
|
||||
console.log(myArray); // [ 'a', 'c' ]
|
||||
console.log(pulled); // [ 'b', 'd' ]
|
||||
</code></pre>
|
||||
</div></div><br/><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) =>
|
||||
isNaN(n)
|
||||
? []
|
||||
: [
|
||||
...quickSort(nums.filter(v => (desc ? v > n : v <= n)), desc),
|
||||
n,
|
||||
...quickSort(nums.filter(v => (!desc ? v > n : v <= 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 class="card fluid"><div class="section double-padded"><h3 id="remove">remove</h3></div><div class="section double-padded">
|
||||
<p>Removes elements from an array for which the given function returns <code>false</code>.</p>
|
||||
<p>Use <code>Array.filter()</code> to find array elements that return truthy values and <code>Array.reduce()</code> to remove elements using <code>Array.splice()</code>.
|
||||
@ -1779,24 +1794,6 @@ Use <code>Number()</code> to check if the coercion holds.</p>
|
||||
</code></pre>
|
||||
<pre><code class="language-js">validateNumber('10'); // true
|
||||
</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) =>
|
||||
isNaN(n)
|
||||
? []
|
||||
: [
|
||||
...quickSort(nums.filter(v => (desc ? v > n : v <= n)), desc),
|
||||
n,
|
||||
...quickSort(nums.filter(v => (!desc ? v > n : v <= 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/>
|
||||
<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>
|
||||
|
||||
Reference in New Issue
Block a user