This file contains 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
/// <summary> | |
/// Gets all possible combinations of the specified list, based on the specified length of each resulting element. | |
/// </summary> | |
/// <typeparam name="T"></typeparam> | |
/// <param name="list"></param> | |
/// <param name="length"></param> | |
/// <param name="check">Additional check before adding an element to the final result. (t1 = IEnumerable of T, t2 = T)</param> | |
/// <returns></returns> | |
static IEnumerable<IEnumerable<T>> GetCombinations<T>(IEnumerable<T> list, int length, | |
Func<IEnumerable<T>, T, bool> check = null) |
This file contains 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
/** | |
* Helper function that creates an object based on an array of values, | |
* setting each key/value with an item from the array. | |
* @param {Array} array The array of values | |
*/ | |
function createEnum(array) { | |
return array.reduce((object, value) => { | |
object[value] = value; | |
return object; |