@pacote/linked-list
Advanced tools
Comparing version 0.7.1 to 0.7.2
@@ -6,2 +6,6 @@ # Change Log | ||
## [0.7.2](https://github.com/PacoteJS/pacote/compare/@pacote/linked-list@0.7.1...@pacote/linked-list@0.7.2) (2023-04-28) | ||
**Note:** Version bump only for package @pacote/linked-list | ||
## [0.7.1](https://github.com/PacoteJS/pacote/compare/@pacote/linked-list@0.7.0...@pacote/linked-list@0.7.1) (2023-04-22) | ||
@@ -8,0 +12,0 @@ |
@@ -22,2 +22,15 @@ import { Option } from '@pacote/option'; | ||
export declare function flatMap<T, R>(callback: MapCallback<T, LinkedList<R>>, list: LinkedList<T>): LinkedList<R>; | ||
/** | ||
* Iterate over all items in the provided list and evaluates a predicate | ||
* function for each one, returning a new list containing only filtered | ||
* items. | ||
* | ||
* @param predicate Predicate function that receives each item. If the function | ||
* returns `true`, the item is included in the filtered list. | ||
* @param list Linked list. | ||
* | ||
* @returns A new list containing only the filtered items. | ||
* | ||
* @category Sublist | ||
*/ | ||
export declare function filter<T>(predicate: PredicateFunction<T>, list: LinkedList<T>): LinkedList<T>; | ||
@@ -24,0 +37,0 @@ export declare function head<T>(list: LinkedList<T>): Option<T>; |
@@ -67,2 +67,15 @@ "use strict"; | ||
exports.flatMap = flatMap; | ||
/** | ||
* Iterate over all items in the provided list and evaluates a predicate | ||
* function for each one, returning a new list containing only filtered | ||
* items. | ||
* | ||
* @param predicate Predicate function that receives each item. If the function | ||
* returns `true`, the item is included in the filtered list. | ||
* @param list Linked list. | ||
* | ||
* @returns A new list containing only the filtered items. | ||
* | ||
* @category Sublist | ||
*/ | ||
function filter(predicate, list) { | ||
@@ -69,0 +82,0 @@ return reverse(reduce(function (acc, value, index, collection) { |
import { LinkedList } from './core'; | ||
/** | ||
* Returns a new [iterator object](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols) | ||
* that contains the key/value pairs for each index in the list. | ||
* | ||
* @param list Linked list. | ||
* | ||
* @returns Entry iterator. | ||
* | ||
* @category Iterator | ||
*/ | ||
export declare function entries<T>(list: LinkedList<T>): IterableIterator<[number, T]>; | ||
/** | ||
* Returns a new [iterator object](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols) | ||
* that contains the keys for each index in the list. | ||
* | ||
* @param list Linked list. | ||
* | ||
* @returns Key iterator. | ||
* | ||
* @category Iterator | ||
*/ | ||
export declare function keys<T>(list: LinkedList<T>): IterableIterator<number>; | ||
/** | ||
* Returns a new [iterator object](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols) | ||
* that contains the values for each index in the list. | ||
* | ||
* @param list Linked list. | ||
* | ||
* @returns Value iterator. | ||
* | ||
* @category Iterator | ||
*/ | ||
export declare function values<T>(list: LinkedList<T>): IterableIterator<T>; |
@@ -25,2 +25,12 @@ "use strict"; | ||
} | ||
/** | ||
* Returns a new [iterator object](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols) | ||
* that contains the key/value pairs for each index in the list. | ||
* | ||
* @param list Linked list. | ||
* | ||
* @returns Entry iterator. | ||
* | ||
* @category Iterator | ||
*/ | ||
function entries(list) { | ||
@@ -30,2 +40,12 @@ return iterator(list, function (key, value) { return [key, value]; }); | ||
exports.entries = entries; | ||
/** | ||
* Returns a new [iterator object](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols) | ||
* that contains the keys for each index in the list. | ||
* | ||
* @param list Linked list. | ||
* | ||
* @returns Key iterator. | ||
* | ||
* @category Iterator | ||
*/ | ||
function keys(list) { | ||
@@ -35,2 +55,12 @@ return iterator(list, function (key) { return key; }); | ||
exports.keys = keys; | ||
/** | ||
* Returns a new [iterator object](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols) | ||
* that contains the values for each index in the list. | ||
* | ||
* @param list Linked list. | ||
* | ||
* @returns Value iterator. | ||
* | ||
* @category Iterator | ||
*/ | ||
function values(list) { | ||
@@ -37,0 +67,0 @@ return iterator(list, function (_, value) { return value; }); |
import { LinkedList } from './core'; | ||
/** | ||
* Drops an arbitrary number of items from the start of a list. | ||
* | ||
* @param offset Number of items to drop. | ||
* @param list Linked list. | ||
* | ||
* @returns A new linked list with the first `offset` list items removed. | ||
* | ||
* @category Sublist | ||
*/ | ||
export declare function drop<T>(offset: number, list: LinkedList<T>): LinkedList<T>; | ||
/** | ||
* Take an arbitrary number of items from the start of a list. | ||
* | ||
* @param offset Number of items to return. | ||
* @param list Linked list. | ||
* | ||
* @returns A new linked list with the first `offset` items of the list. | ||
* | ||
* @category Sublist | ||
*/ | ||
export declare function take<T>(offset: number, list: LinkedList<T>): LinkedList<T>; | ||
/** | ||
* Creates a subset of elements from a start index (inclusive) till the end of | ||
* the list. | ||
* | ||
* @param start Starting index (inclusive). | ||
* @param list Linked list. | ||
* | ||
* @returns A new linked list with a subset of elements between `start` and | ||
* the end of the list. | ||
* | ||
* @category Sublist | ||
*/ | ||
export declare function slice<T>(start: number, list: LinkedList<T>): LinkedList<T>; | ||
/** | ||
* Creates a subset of elements from a start index (inclusive) to an end | ||
* index (non-inclusive) of the list. | ||
* | ||
* @param start Starting index (inclusive). | ||
* @param end Ending index (non-inclusive). | ||
* @param list Linked list. | ||
* | ||
* @returns A new linked list with a subset of elements between `start` and | ||
* `end` of the list. | ||
* | ||
* @category Sublist | ||
*/ | ||
export declare function slice<T>(start: number, end: number, list: LinkedList<T>): LinkedList<T>; | ||
/** | ||
* Removes the item at a specified index from a list. | ||
* | ||
* @param index Index of the item to remove. | ||
* @param list Linked list. | ||
* | ||
* @returns A new linked list with the item at index `index` removed. | ||
* | ||
* @category Sublist | ||
*/ | ||
export declare function remove<T>(index: number, list: LinkedList<T>): LinkedList<T>; | ||
/** | ||
* Get the unique items of a list. | ||
* | ||
* @param list Linked list. | ||
* | ||
* @returns A new linked list with a subset of elements that are unique. | ||
* | ||
* @category Sublist | ||
*/ | ||
export declare function unique<T>(list: LinkedList<T>): LinkedList<T>; |
@@ -6,2 +6,12 @@ "use strict"; | ||
var search_1 = require("./search"); | ||
/** | ||
* Drops an arbitrary number of items from the start of a list. | ||
* | ||
* @param offset Number of items to drop. | ||
* @param list Linked list. | ||
* | ||
* @returns A new linked list with the first `offset` list items removed. | ||
* | ||
* @category Sublist | ||
*/ | ||
function drop(offset, list) { | ||
@@ -16,2 +26,12 @@ return offset > 0 ? drop(offset - 1, (0, core_1.cdr)(list)) : list; | ||
} | ||
/** | ||
* Take an arbitrary number of items from the start of a list. | ||
* | ||
* @param offset Number of items to return. | ||
* @param list Linked list. | ||
* | ||
* @returns A new linked list with the first `offset` items of the list. | ||
* | ||
* @category Sublist | ||
*/ | ||
function take(offset, list) { | ||
@@ -28,2 +48,12 @@ return recursiveTake((0, core_1.emptyList)(), offset, list); | ||
exports.slice = slice; | ||
/** | ||
* Removes the item at a specified index from a list. | ||
* | ||
* @param index Index of the item to remove. | ||
* @param list Linked list. | ||
* | ||
* @returns A new linked list with the item at index `index` removed. | ||
* | ||
* @category Sublist | ||
*/ | ||
function remove(index, list) { | ||
@@ -33,2 +63,11 @@ return (0, core_1.concat)(take(index, list), drop(index + 1, list)); | ||
exports.remove = remove; | ||
/** | ||
* Get the unique items of a list. | ||
* | ||
* @param list Linked list. | ||
* | ||
* @returns A new linked list with a subset of elements that are unique. | ||
* | ||
* @category Sublist | ||
*/ | ||
function unique(list) { | ||
@@ -35,0 +74,0 @@ return (0, core_1.reverse)((0, core_1.reduce)(function (uniqueValues, value) { |
@@ -22,2 +22,15 @@ import { Option } from '@pacote/option'; | ||
export declare function flatMap<T, R>(callback: MapCallback<T, LinkedList<R>>, list: LinkedList<T>): LinkedList<R>; | ||
/** | ||
* Iterate over all items in the provided list and evaluates a predicate | ||
* function for each one, returning a new list containing only filtered | ||
* items. | ||
* | ||
* @param predicate Predicate function that receives each item. If the function | ||
* returns `true`, the item is included in the filtered list. | ||
* @param list Linked list. | ||
* | ||
* @returns A new list containing only the filtered items. | ||
* | ||
* @category Sublist | ||
*/ | ||
export declare function filter<T>(predicate: PredicateFunction<T>, list: LinkedList<T>): LinkedList<T>; | ||
@@ -24,0 +37,0 @@ export declare function head<T>(list: LinkedList<T>): Option<T>; |
@@ -47,2 +47,15 @@ import { None, Some } from '@pacote/option'; | ||
} | ||
/** | ||
* Iterate over all items in the provided list and evaluates a predicate | ||
* function for each one, returning a new list containing only filtered | ||
* items. | ||
* | ||
* @param predicate Predicate function that receives each item. If the function | ||
* returns `true`, the item is included in the filtered list. | ||
* @param list Linked list. | ||
* | ||
* @returns A new list containing only the filtered items. | ||
* | ||
* @category Sublist | ||
*/ | ||
export function filter(predicate, list) { | ||
@@ -49,0 +62,0 @@ return reverse(reduce((acc, value, index, collection) => predicate(value, index, collection) ? prepend(value, acc) : acc, emptyList(), list)); |
import { LinkedList } from './core'; | ||
/** | ||
* Returns a new [iterator object](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols) | ||
* that contains the key/value pairs for each index in the list. | ||
* | ||
* @param list Linked list. | ||
* | ||
* @returns Entry iterator. | ||
* | ||
* @category Iterator | ||
*/ | ||
export declare function entries<T>(list: LinkedList<T>): IterableIterator<[number, T]>; | ||
/** | ||
* Returns a new [iterator object](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols) | ||
* that contains the keys for each index in the list. | ||
* | ||
* @param list Linked list. | ||
* | ||
* @returns Key iterator. | ||
* | ||
* @category Iterator | ||
*/ | ||
export declare function keys<T>(list: LinkedList<T>): IterableIterator<number>; | ||
/** | ||
* Returns a new [iterator object](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols) | ||
* that contains the values for each index in the list. | ||
* | ||
* @param list Linked list. | ||
* | ||
* @returns Value iterator. | ||
* | ||
* @category Iterator | ||
*/ | ||
export declare function values<T>(list: LinkedList<T>): IterableIterator<T>; |
@@ -21,8 +21,38 @@ import { car, cdr, isEmpty } from './core'; | ||
} | ||
/** | ||
* Returns a new [iterator object](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols) | ||
* that contains the key/value pairs for each index in the list. | ||
* | ||
* @param list Linked list. | ||
* | ||
* @returns Entry iterator. | ||
* | ||
* @category Iterator | ||
*/ | ||
export function entries(list) { | ||
return iterator(list, (key, value) => [key, value]); | ||
} | ||
/** | ||
* Returns a new [iterator object](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols) | ||
* that contains the keys for each index in the list. | ||
* | ||
* @param list Linked list. | ||
* | ||
* @returns Key iterator. | ||
* | ||
* @category Iterator | ||
*/ | ||
export function keys(list) { | ||
return iterator(list, (key) => key); | ||
} | ||
/** | ||
* Returns a new [iterator object](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols) | ||
* that contains the values for each index in the list. | ||
* | ||
* @param list Linked list. | ||
* | ||
* @returns Value iterator. | ||
* | ||
* @category Iterator | ||
*/ | ||
export function values(list) { | ||
@@ -29,0 +59,0 @@ return iterator(list, (_, value) => value); |
import { LinkedList } from './core'; | ||
/** | ||
* Drops an arbitrary number of items from the start of a list. | ||
* | ||
* @param offset Number of items to drop. | ||
* @param list Linked list. | ||
* | ||
* @returns A new linked list with the first `offset` list items removed. | ||
* | ||
* @category Sublist | ||
*/ | ||
export declare function drop<T>(offset: number, list: LinkedList<T>): LinkedList<T>; | ||
/** | ||
* Take an arbitrary number of items from the start of a list. | ||
* | ||
* @param offset Number of items to return. | ||
* @param list Linked list. | ||
* | ||
* @returns A new linked list with the first `offset` items of the list. | ||
* | ||
* @category Sublist | ||
*/ | ||
export declare function take<T>(offset: number, list: LinkedList<T>): LinkedList<T>; | ||
/** | ||
* Creates a subset of elements from a start index (inclusive) till the end of | ||
* the list. | ||
* | ||
* @param start Starting index (inclusive). | ||
* @param list Linked list. | ||
* | ||
* @returns A new linked list with a subset of elements between `start` and | ||
* the end of the list. | ||
* | ||
* @category Sublist | ||
*/ | ||
export declare function slice<T>(start: number, list: LinkedList<T>): LinkedList<T>; | ||
/** | ||
* Creates a subset of elements from a start index (inclusive) to an end | ||
* index (non-inclusive) of the list. | ||
* | ||
* @param start Starting index (inclusive). | ||
* @param end Ending index (non-inclusive). | ||
* @param list Linked list. | ||
* | ||
* @returns A new linked list with a subset of elements between `start` and | ||
* `end` of the list. | ||
* | ||
* @category Sublist | ||
*/ | ||
export declare function slice<T>(start: number, end: number, list: LinkedList<T>): LinkedList<T>; | ||
/** | ||
* Removes the item at a specified index from a list. | ||
* | ||
* @param index Index of the item to remove. | ||
* @param list Linked list. | ||
* | ||
* @returns A new linked list with the item at index `index` removed. | ||
* | ||
* @category Sublist | ||
*/ | ||
export declare function remove<T>(index: number, list: LinkedList<T>): LinkedList<T>; | ||
/** | ||
* Get the unique items of a list. | ||
* | ||
* @param list Linked list. | ||
* | ||
* @returns A new linked list with a subset of elements that are unique. | ||
* | ||
* @category Sublist | ||
*/ | ||
export declare function unique<T>(list: LinkedList<T>): LinkedList<T>; |
import { car, cdr, concat, reverse, emptyList, prepend, isEmpty, reduce, } from './core'; | ||
import { includes } from './search'; | ||
/** | ||
* Drops an arbitrary number of items from the start of a list. | ||
* | ||
* @param offset Number of items to drop. | ||
* @param list Linked list. | ||
* | ||
* @returns A new linked list with the first `offset` list items removed. | ||
* | ||
* @category Sublist | ||
*/ | ||
export function drop(offset, list) { | ||
@@ -11,2 +21,12 @@ return offset > 0 ? drop(offset - 1, cdr(list)) : list; | ||
} | ||
/** | ||
* Take an arbitrary number of items from the start of a list. | ||
* | ||
* @param offset Number of items to return. | ||
* @param list Linked list. | ||
* | ||
* @returns A new linked list with the first `offset` items of the list. | ||
* | ||
* @category Sublist | ||
*/ | ||
export function take(offset, list) { | ||
@@ -21,5 +41,24 @@ return recursiveTake(emptyList(), offset, list); | ||
} | ||
/** | ||
* Removes the item at a specified index from a list. | ||
* | ||
* @param index Index of the item to remove. | ||
* @param list Linked list. | ||
* | ||
* @returns A new linked list with the item at index `index` removed. | ||
* | ||
* @category Sublist | ||
*/ | ||
export function remove(index, list) { | ||
return concat(take(index, list), drop(index + 1, list)); | ||
} | ||
/** | ||
* Get the unique items of a list. | ||
* | ||
* @param list Linked list. | ||
* | ||
* @returns A new linked list with a subset of elements that are unique. | ||
* | ||
* @category Sublist | ||
*/ | ||
export function unique(list) { | ||
@@ -26,0 +65,0 @@ return reverse(reduce((uniqueValues, value) => includes(value, uniqueValues) |
{ | ||
"name": "@pacote/linked-list", | ||
"description": "Immutable linked lists.", | ||
"version": "0.7.1", | ||
"version": "0.7.2", | ||
"sideEffects": false, | ||
@@ -39,3 +39,3 @@ "license": "MIT", | ||
}, | ||
"gitHead": "d0e1f3f1f0b32a28cf51f226dd2c9d247503b4ee" | ||
"gitHead": "5cb2e6cba6f049113214dee6265c6d544ca04305" | ||
} |
@@ -172,52 +172,2 @@ # @pacote/linked-list | ||
### Sublist functions | ||
#### `filter<T>(predicate: (element: T, index: number, collection: LinkedList<T>) => boolean, list: LinkedList<T>): LinkedList<T>` | ||
`filter()` iterates over all items in the provided list and evaluates the | ||
`predicate` function for each one, returning a new list containing only | ||
the items for which the `predicate` function yielded `true`. | ||
#### `remove<T>(index: number, list: LinkedList<T>): LinkedList<T>` | ||
`remove()` returns a new linked list with the element at `index` removed. | ||
#### `take<T>(count: number, list: LinkedList<T>): LinkedList<T>` | ||
`take()` returns the first `count` elements of a list. | ||
#### `drop<T>(count: number, list: LinkedList<T>): LinkedList<T>` | ||
`drop()` returns a list with the first `count` elements of the provided | ||
list removed. | ||
#### `slice<T>(start: number, end?: number, list: LinkedList<T>): LinkedList<T>` | ||
`slice()` returns a new linked list with a subset of elements between | ||
indices `start` (inclusive) and `end` (non-inclusive). If `end` is | ||
omitted, the function returns a slice between `start` and the end of the | ||
list. | ||
#### `unique<T>(list: LinkedList<T>): LinkedList<T>` | ||
`unique()` returns a new linked list with a subset of elements from the provided | ||
`list` that are unique. | ||
### Iterator functions | ||
#### `entries<T>(list: LinkedList<T>): IterableIterator<[number, T]>` | ||
`entries()` returns a new [iterator object](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols) | ||
that contains the key/value pairs for each index in the list. | ||
#### `keys<T>(list: LinkedList<T>): IterableIterator<number>` | ||
`keys()` returns a new [iterator object](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols) | ||
that contains the values for each index in the list. | ||
#### `values<T>(list: LinkedList<T>): IterableIterator<T>` | ||
`values()` returns a new [iterator object](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols) | ||
that contains the values of each element in the list. | ||
## See also | ||
@@ -224,0 +174,0 @@ |
@@ -116,2 +116,15 @@ import { None, Option, Some } from '@pacote/option' | ||
/** | ||
* Iterate over all items in the provided list and evaluates a predicate | ||
* function for each one, returning a new list containing only filtered | ||
* items. | ||
* | ||
* @param predicate Predicate function that receives each item. If the function | ||
* returns `true`, the item is included in the filtered list. | ||
* @param list Linked list. | ||
* | ||
* @returns A new list containing only the filtered items. | ||
* | ||
* @category Sublist | ||
*/ | ||
export function filter<T>( | ||
@@ -118,0 +131,0 @@ predicate: PredicateFunction<T>, |
@@ -26,2 +26,12 @@ import { car, cdr, isEmpty, LinkedList } from './core' | ||
/** | ||
* Returns a new [iterator object](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols) | ||
* that contains the key/value pairs for each index in the list. | ||
* | ||
* @param list Linked list. | ||
* | ||
* @returns Entry iterator. | ||
* | ||
* @category Iterator | ||
*/ | ||
export function entries<T>(list: LinkedList<T>): IterableIterator<[number, T]> { | ||
@@ -31,2 +41,12 @@ return iterator(list, (key, value) => [key, value]) | ||
/** | ||
* Returns a new [iterator object](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols) | ||
* that contains the keys for each index in the list. | ||
* | ||
* @param list Linked list. | ||
* | ||
* @returns Key iterator. | ||
* | ||
* @category Iterator | ||
*/ | ||
export function keys<T>(list: LinkedList<T>): IterableIterator<number> { | ||
@@ -36,4 +56,14 @@ return iterator(list, (key) => key) | ||
/** | ||
* Returns a new [iterator object](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols) | ||
* that contains the values for each index in the list. | ||
* | ||
* @param list Linked list. | ||
* | ||
* @returns Value iterator. | ||
* | ||
* @category Iterator | ||
*/ | ||
export function values<T>(list: LinkedList<T>): IterableIterator<T> { | ||
return iterator(list, (_, value) => value) | ||
} |
@@ -14,2 +14,12 @@ import { | ||
/** | ||
* Drops an arbitrary number of items from the start of a list. | ||
* | ||
* @param offset Number of items to drop. | ||
* @param list Linked list. | ||
* | ||
* @returns A new linked list with the first `offset` list items removed. | ||
* | ||
* @category Sublist | ||
*/ | ||
export function drop<T>(offset: number, list: LinkedList<T>): LinkedList<T> { | ||
@@ -29,2 +39,12 @@ return offset > 0 ? drop(offset - 1, cdr(list)) : list | ||
/** | ||
* Take an arbitrary number of items from the start of a list. | ||
* | ||
* @param offset Number of items to return. | ||
* @param list Linked list. | ||
* | ||
* @returns A new linked list with the first `offset` items of the list. | ||
* | ||
* @category Sublist | ||
*/ | ||
export function take<T>(offset: number, list: LinkedList<T>): LinkedList<T> { | ||
@@ -34,3 +54,28 @@ return recursiveTake(emptyList(), offset, list) | ||
/** | ||
* Creates a subset of elements from a start index (inclusive) till the end of | ||
* the list. | ||
* | ||
* @param start Starting index (inclusive). | ||
* @param list Linked list. | ||
* | ||
* @returns A new linked list with a subset of elements between `start` and | ||
* the end of the list. | ||
* | ||
* @category Sublist | ||
*/ | ||
export function slice<T>(start: number, list: LinkedList<T>): LinkedList<T> | ||
/** | ||
* Creates a subset of elements from a start index (inclusive) to an end | ||
* index (non-inclusive) of the list. | ||
* | ||
* @param start Starting index (inclusive). | ||
* @param end Ending index (non-inclusive). | ||
* @param list Linked list. | ||
* | ||
* @returns A new linked list with a subset of elements between `start` and | ||
* `end` of the list. | ||
* | ||
* @category Sublist | ||
*/ | ||
export function slice<T>( | ||
@@ -52,2 +97,12 @@ start: number, | ||
/** | ||
* Removes the item at a specified index from a list. | ||
* | ||
* @param index Index of the item to remove. | ||
* @param list Linked list. | ||
* | ||
* @returns A new linked list with the item at index `index` removed. | ||
* | ||
* @category Sublist | ||
*/ | ||
export function remove<T>(index: number, list: LinkedList<T>): LinkedList<T> { | ||
@@ -57,2 +112,11 @@ return concat(take(index, list), drop(index + 1, list)) | ||
/** | ||
* Get the unique items of a list. | ||
* | ||
* @param list Linked list. | ||
* | ||
* @returns A new linked list with a subset of elements that are unique. | ||
* | ||
* @category Sublist | ||
*/ | ||
export function unique<T>(list: LinkedList<T>): LinkedList<T> { | ||
@@ -59,0 +123,0 @@ return reverse( |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
122744
2384
179