Skip to content

Commit

Permalink
🐛 chore: clean TODO
Browse files Browse the repository at this point in the history
  • Loading branch information
wolfram77 committed May 7, 2023
1 parent f552871 commit b99b642
Show file tree
Hide file tree
Showing 7 changed files with 225 additions and 173 deletions.
133 changes: 71 additions & 62 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,29 +70,28 @@ xarray.permutations([1, 2, 3]);

| Property | Description |
| ---- | ---- |
| [fromIterable] | Convert an iterable to array. |
| [fromIterable$] | Convert an iterable to array! |
| [fromRange] | Generate array from given number range. |
| [fromInvocation] | Generate array from repeated function invocation. |
| [fromApplication] | Generate array from repeated function application. |
| [fromIterable] | Convert an iterable to array. |
| [fromIterable$] | Convert an iterable to array! |
| | |
| [shallowClone] | Shallow clone an array. |
| [deepClone] | Deep clone an array. |
| | |
| [is] | Check if value is an array. |
| [isSorted] | Examine if array is sorted. |
| [keys] | Obtain all indices. |
| [values] | Get all values. |
| [values$] | Get all values! |
| [entries] | Obtain all index-value pairs. |
| [ikeys] | List all indices. |
| [ivalues] | List all values. |
| [ientries] | List all index-value pairs. |
| | |
| [index] | Get zero-based index for an element in array. |
| [indexRange] | Get zero-based index range for part of array. |
| [length] | Find the length of an array. |
| | |
| [isEmpty] | Check if an array is empty. |
| [length] | Find the length of an array. |
| [resize$] | Resize an array to given length! |
| [clear$] | Remove all elements from an array! |
| | |
Expand All @@ -111,17 +110,17 @@ xarray.permutations([1, 2, 3]);
| [remove$] | Remove value at index! |
| [removePath$] | Remove value at path in a nested array! |
| | |
| [count] | Count values which satisfy a test. |
| [countEach] | Count occurrences of each distinct value. |
| [min] | Find first smallest value. |
| [minEntry] | Find first smallest entry. |
| [max] | Find first largest value. |
| [maxEntry] | Find first largest entry. |
| [minimum] | Find first smallest value. |
| [minimumEntry] | Find first smallest entry. |
| [maximum] | Find first largest value. |
| [maximumEntry] | Find first largest entry. |
| [range] | Find smallest and largest values. |
| [rangeEntries] | Find smallest and largest entries. |
| [searchMinimumValue] | Find first index of minimum value. |
| [searchMaximumValue] | Find first index of maximum value. |
| | |
| [compare] | Compare two arrays (lexicographically). |
| [isEqual] | Examine if two arrays are equal. |
| [compare] | Compare two arrays (lexicographically). |
| | |
| [head] | Get first value. |
| [last] | Get last value. |
Expand All @@ -130,6 +129,10 @@ xarray.permutations([1, 2, 3]);
| [init] | Get values except last. |
| [slice] | Get part of an array. |
| [slice$] | Get part of an array! |
| | |
| [find] | Find first value passing a test. |
| [findRight] | Find last value passing a test. |
| | |
| [take] | Keep first n values only. |
| [takeRight] | Keep last n values only. |
| [takeWhile] | Keep values from left, while a test passes. |
Expand All @@ -139,55 +142,52 @@ xarray.permutations([1, 2, 3]);
| [dropWhile] | Discard values from left, while a test passes. |
| [dropWhileRight] | Discard values from right, while a test passes. |
| | |
| [prefixes] | Obtain all possible prefixes. |
| [suffixes] | Obtain all possible suffixes. |
| [infixes] | Obtain all possible infixes. |
| [subsequences] | Obtain all possible subsequences. |
| [permutations] | Obtain all possible permutations. |
| [iprefixes] | List all possible prefixes. |
| [isuffixes] | List all possible suffixes. |
| [iinfixes] | List all possible infixes. |
| [isubsequences] | List all possible subsequences. |
| [ipermutations] | List all possible permutations. |
| [randomValue] | Pick an arbitrary value. |
| [randomPrefix] | Pick an arbitrary prefix. |
| [randomSuffix] | Pick an arbitrary suffix. |
| [randomInfix] | Pick an arbitrary infix. |
| [randomSubsequence] | Pick an arbitrary subsequence. |
| [randomPermutation] | Pick an arbitrary permutation. |
| [randomPermutation$] | Pick an arbitrary permutation! |
| | |
| [includes] | Check if array has a value. |
| [indexOf] | Find first index of a value. |
| [lastIndexOf] | Find last index of a value. |
| [find] | Find first value passing a test. |
| [findRight] | Find last value passing a test. |
| [scanWhile] | Scan from left, while a test passes. |
| [scanWhileRight] | Scan from right, while a test passes. |
| [scanUntil] | Scan from left, until a test passes. |
| [scanUntilRight] | Scan from right, until a test passes. |
| | |
| [indexOf] | Find first index of a value. |
| [lastIndexOf] | Find last index of a value. |
| [search] | Find index of first value passing a test. |
| [searchRight] | Find index of last value passing a test. |
| [searchAll] | Find indices of values passing a test. |
| | |
| [includes] | Check if array has a value. |
| [hasValue] | Examine if array has a value. |
| [searchValue] | Find first index of a value. |
| [searchValueRight] | Find last index of a value. |
| [searchValueAll] | Find indices of value. |
| [searchMinimumValue] | Find first index of minimum value. |
| [searchMaximumValue] | Find first index of maximum value. |
| [searchUnsortedValue] | Find first index of an unsorted value. |
| [searchAdjacentDuplicateValue] | Find first index of an adjacent duplicate value. |
| [searchMismatchedValue] | Find first index where two arrays differ. |
| [searchInfix] | Find first index of an infix. |
| [searchInfixRight] | Find last index of an infix. |
| [searchInfixAll] | Find indices of an infix. |
| [searchSubsequence] | Find first index of a subsequence. |
| [hasValue] | Examine if array has a value. |
| [hasUnsortedValue] | Examine if array has an unsorted value. |
| | |
| [hasPrefix] | Examine if array starts with a prefix. |
| [hasSuffix] | Examine if array ends with a suffix. |
| [hasInfix] | Examine if array contains an infix. |
| [hasSubsequence] | Examine if array has a subsequence. |
| [hasPermutation] | Examine if array has a permutation. |
| [prefixes] | Obtain all possible prefixes. |
| [suffixes] | Obtain all possible suffixes. |
| [infixes] | Obtain all possible infixes. |
| [subsequences] | Obtain all possible subsequences. |
| [permutations] | Obtain all possible permutations. |
| [iprefixes] | List all possible prefixes. |
| [isuffixes] | List all possible suffixes. |
| [iinfixes] | List all possible infixes. |
| [isubsequences] | List all possible subsequences. |
| [ipermutations] | List all possible permutations. |
| [searchInfix] | Find first index of an infix. |
| [searchInfixRight] | Find last index of an infix. |
| [searchInfixAll] | Find indices of an infix. |
| [searchSubsequence] | Find first index of a subsequence. |
| | |
| [randomValue] | Pick an arbitrary value. |
| [randomPrefix] | Pick an arbitrary prefix. |
| [randomSuffix] | Pick an arbitrary suffix. |
| [randomInfix] | Pick an arbitrary infix. |
| [randomSubsequence] | Pick an arbitrary subsequence. |
| [randomPermutation] | Pick an arbitrary permutation. |
| [randomPermutation$] | Pick an arbitrary permutation! |
| | |
| [forEach] | Call a function for each value. |
| [some] | Examine if any value satisfies a test. |
Expand All @@ -196,23 +196,24 @@ xarray.permutations([1, 2, 3]);
| [map$] | Transform values of an array! |
| [reduce] | Reduce values of array to a single value. |
| [reduceRight] | Reduce values from right, to a single value. |
| [exclusiveScan] | Perform exclusive prefix scan from left to right. |
| [exclusiveScan$] | Perform exclusive prefix scan from left to right! |
| [inclusiveScan] | Perform inclusive prefix scan from left to right. |
| [inclusiveScan$] | Perform inclusive prefix scan from left to right! |
| [adjacentCombine] | Combine adjacent values of an array. |
| [adjacentCombine$] | Combine adjacent values of an array! |
| [filter] | Keep values which pass a test. |
| [filter$] | Keep values which pass a test! |
| [filterAt] | Keep values at given indices. |
| [reject] | Discard values which pass a test. |
| [reject$] | Discard values which pass a test! |
| [rejectAt] | Discard values at given indices. |
| [accumulate] | Produce accumulating values. |
| [flat] | Flatten nested array to given depth. |
| [flatMap] | Flatten nested array, based on map function. |
| [zip] | Combine values from arrays. |
| | |
| [accumulate] | Produce accumulating values. |
| [exclusiveScan] | Perform exclusive prefix scan from left to right. |
| [exclusiveScan$] | Perform exclusive prefix scan from left to right! |
| [inclusiveScan] | Perform inclusive prefix scan from left to right. |
| [inclusiveScan$] | Perform inclusive prefix scan from left to right! |
| [adjacentCombine] | Combine adjacent values of an array. |
| [adjacentCombine$] | Combine adjacent values of an array! |
| | |
| [fill] | Fill with given value. |
| [fill$] | Fill with given value! |
| [push] | Add value to the end. |
Expand All @@ -231,22 +232,27 @@ xarray.permutations([1, 2, 3]);
| [moveWithin$] | Move part of array within! |
| [splice] | Remove or replace existing values. |
| [splice$] | Remove or replace existing values! |
| | |
| [count] | Count values which satisfy a test. |
| [countEach] | Count occurrences of each distinct value. |
| [partition] | Segregate values by test result. |
| [partitionEach] | Segregate each distinct value. |
| | |
| [split] | Break array considering test as separator. |
| [splitAt] | Break array considering indices as separator. |
| [cut] | Break array when test passes. |
| [cutRight] | Break array after test passes. |
| [cutAt] | Break array at given indices. |
| [cutAtRight] | Break array after given indices. |
| [group] | Keep similar values together and in order. |
| [partition] | Segregate values by test result. |
| [partitionEach] | Segregate each distinct value. |
| [chunk] | Break array into chunks of given size. |
| [cycle] | Obtain values that cycle through array. |
| [repeat] | Repeat an array given times. |
| [reverse] | Reverse the values. |
| [reverse$] | Reverse the values! |
| [rotate] | Rotate values in array. |
| [rotate$] | Rotate values in array! |
| | |
| [intersperse] | Place a separator between every value. |
| [interpolate] | Estimate new values between existing ones. |
| [intermix] | Place values of an array between another. |
Expand All @@ -256,6 +262,14 @@ xarray.permutations([1, 2, 3]);
| [concat$] | Append values from arrays! |
| [join] | Join values together into a string. |
| | |
| [isSorted] | Examine if array is sorted. |
| [hasUnsortedValue] | Examine if array has an unsorted value. |
| [searchUnsortedValue] | Find first index of an unsorted value. |
| [sort] | Arrange values in order. |
| [sort$] | Arrange values in order! |
| [partialSort] | Partially arrange values in order. |
| [partialSort$] | Partially arrange values in order! |
| | |
| [isUnique] | Examine if there are no duplicate values. |
| [isDisjoint] | Examine if arrays have no value in common. |
| [unique] | Remove duplicate values. |
Expand All @@ -265,11 +279,6 @@ xarray.permutations([1, 2, 3]);
| [difference] | Obtain values not present in another array. |
| [symmetricDifference] | Obtain values not present in both arrays. |
| [cartesianProduct] | Obtain cartesian product of arrays. |
| | |
| [sort] | Arrange values in order. |
| [sort$] | Arrange values in order! |
| [partialSort] | Partially arrange values in order. |
| [partialSort$] | Partially arrange values in order! |

<br>
<br>
Expand Down Expand Up @@ -324,10 +333,10 @@ xarray.permutations([1, 2, 3]);
[removePath$]: https://github.com/nodef/extra-array/wiki/removePath$
[count]: https://github.com/nodef/extra-array/wiki/count
[countEach]: https://github.com/nodef/extra-array/wiki/countEach
[min]: https://github.com/nodef/extra-array/wiki/min
[minEntry]: https://github.com/nodef/extra-array/wiki/minEntry
[max]: https://github.com/nodef/extra-array/wiki/max
[maxEntry]: https://github.com/nodef/extra-array/wiki/maxEntry
[minimum]: https://github.com/nodef/extra-array/wiki/minimum
[minimumEntry]: https://github.com/nodef/extra-array/wiki/minimumEntry
[maximum]: https://github.com/nodef/extra-array/wiki/maximum
[maximumEntry]: https://github.com/nodef/extra-array/wiki/maximumEntry
[range]: https://github.com/nodef/extra-array/wiki/range
[rangeEntries]: https://github.com/nodef/extra-array/wiki/rangeEntries
[slice]: https://github.com/nodef/extra-array/wiki/slice
Expand Down
91 changes: 0 additions & 91 deletions TODO
Original file line number Diff line number Diff line change
@@ -1,97 +1,6 @@
SORTS, IN PAIR

Instead of mapFn, provide pair array to define sort mapping.
selectionSort, insertionSort, bubbleSort, mergeSort, (are all stable?)
quickSort, shellSort, radixSort, timSort, heapSort
https://en.wikipedia.org/wiki/Sorting_algorithm
https://www.npmjs.com/package/sort-algorithms-js
https://dl.acm.org/doi/10.5555/1778580.1778601
https://stackoverflow.com/questions/463105/in-place-radix-sort/474040#474040


MINNTH, MAXNTH, SORTEDSLICE (ARRAYVIEW)

Need only part of sorted array? [bag][nth] ...
Selection algorithm: Quickselect
https://stackoverflow.com/questions/34395680/what-is-the-fastest-way-to-find-nth-biggest-number-of-an-int-array
https://www.geeksforgeeks.org/kth-smallestlargest-element-unsorted-array/


PARSE, OTHERS
- (fm, fc)?


INDEX -VE
- moveWithin


OLD SORT ALGORITHMS

/**
* Arrange values in order!
* @param x an array (updated!)
* @param fc compare function (a, b)
* @param fm map function (v, i, x)
* @param fs swap function (x, i, j)
* @returns x | x[i] ≤ x[j] ∀ i ≤ j
*/
function bubbleSort$<T, U=T>(x: T[], fc: CompareFunction<T|U> | null=null, fm: MapFunction<T, T|U> | null=null, fs: SwapFunction<T> | null=null): T[] {
var fc = fc || COMPARE;
var fm = fm || IDENTITY; // TODO: use map function
var fs = fs || swap$;
var X = x.length;
for (var i=0; i<X-1; ++i) {
for (var j=i+1; j<X; ++j)
if (fc(x[i], x[j]) > 0) fs(x, i, j);
}
return x;
}


/**
* Arrange values in order!
* @param x an array (updated!)
* @param fc compare function (a, b)
* @param fm map function (v, i, x)
* @param fs swap function (x, i, j)
* @returns x | x[i] ≤ x[j] ∀ i ≤ j
*/
function selectionSort$<T, U=T>(x: T[], fc: CompareFunction<T|U> | null=null, fm: MapFunction<T, T|U> | null=null, fs: SwapFunction<T> | null=null): T[] {
var fc = fc || COMPARE;
var fm = fm || IDENTITY; // TODO: use map function
var fs = fs || swap$;
var X = x.length;
for (var i=0; i<X-1; ++i) {
var l = i;
for (var j=i+1; j<X; ++j)
if (fc(x[l], x[j]) > 0) l = j;
fs(x, i, l);
}
return x;
}


// TODO: Check if this is correct!
/**
* Arrange values in order!
* @param x an array (updated!)
* @param fc compare function (a, b)
* @param fm map function (v, i, x)
* @param fs swap function (x, i, j)
* @returns x | x[i] ≤ x[j] ∀ i ≤ j
*/
function insertionSortOld$<T, U=T>(x: T[], fc: CompareFunction<T|U> | null=null, fm: MapFunction<T, T|U> | null=null, fs: SwapFunction<T> | null=null): T[] {
var fc = fc || COMPARE;
var fm = fm || IDENTITY; // TODO: use map function
var fs = fs || swap$; // TODO: use swap function
var X = x.length;
for (var i=X-2; i>=0; --i) {
var xv = x[i], mv = x[i];
for (var j=i+1; j<X; j++) {
if (fc(mv, x[j]) <= 0) break;
x[j-1] = x[j];
}
x[j-1] = xv;
}
return x;
}
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "extra-array",
"version": "4.0.1",
"version": "4.0.2",
"description": "An array is a collection of values, stored contiguously.",
"main": "index.js",
"module": "index.mjs",
Expand Down
Loading

0 comments on commit b99b642

Please sign in to comment.