How to use the reduceRight function from ramda
Find comprehensive JavaScript ramda.reduceRight code examples handpicked from public code repositorys.
32 33 34 35 36 37 38 39 40 41 42 43 44
const loadCreatorAndApplyArgs = ([creator, ...args]) => normalizeLoaded(creator)(...args) const normalize = r => (type(r) === 'Array' ? loadCreatorAndApplyArgs(r) : normalizeLoaded(r)) const mergePipes = reduceRight( mergeWith((x, y) => flatten([x, y])), {} )
2
5
0
3886 3887 3888 3889 3890 3891 3892 3893 3894 3895
* @example * * var pairs = [ ['a', 1], ['b', 2], ['c', 3] ]; * var flattenPairs = (acc, pair) => acc.concat(pair); * * R.reduceRight(flattenPairs, [], pairs); //=> [ 'c', 3, 'b', 2, 'a', 1 ] */ var reduceRight = _curry3(function reduceRight(fn, acc, list) { var idx = list.length - 1; while (idx >= 0) {
0
0
0
+ 17 other calls in file
GitHub: octachrome/t2
21 22 23 24 25 26 27 28 29 30 31 32 33 34
const Rand = { _nextSeed: seed => R.append(pureRandom.randUint(seed), R.slice(1, 4, seed)), _random: (seed, min, max) => Math.round(min + pureRandom.randUint(seed) / UINT32_MAX * (max - min)), makeSeed: (iseed, n) => iseed ? R.reduceRight(R.compose, R.identity, R.repeat(Rand._nextSeed, n || 10))(PRIMES.map(p => p * iseed)) : pureRandom.genSeed(), random: (min, max) => State(seed => Pair(Rand._random(seed, min, max), Rand._nextSeed(seed))), shuffle: list => list.length <= 1 ? State.of(list) :
0
0
0
+ 6 other calls in file
GitHub: octachrome/t2
36 37 38 39 40 41 42 43 44 45 46 47 48
const UINT32_MAX = Math.pow(2, 32) - 1; const PRIMES = [160481183, 179424673, 198491317, 217645177]; const nextGen = gen => R.append(pureRandom.randUint(gen), R.slice(1, 4, gen)); const mkStdGen = (seed, n) => seed ? R.reduceRight(R.compose, R.identity, R.repeat(nextGen, n || 10))(PRIMES.map(p => p * seed)) : pureRandom.genSeed(); const random = (seed, min, max) => Math.round(min + pureRandom.randUint(seed) / UINT32_MAX * (max - min)); const foldM = (f, a, list) => { const foldMonadicAcc = (f, ma, list) => list.length == 0 ? ma : ma.chain(a => foldMonadicAcc(f, f(a, list[0]), R.remove(0, 1, list)));
0
0
0
+ 4 other calls in file
31 32 33 34 35 36 37 38 39 40 41 42 43
? 1 : R.sum(R.map((index) => accumMap[index], branches)) return accumMap } const combinationsMap = R.reduceRight(combinationsForIndex, [], indexRange) console.log(`Total possible arrangements: ${R.head(combinationsMap)}`) //@emandrada style!
0
0
0
184 185 186 187 188 189 190 191 192 193
}, population)) return step(newPopulation, n + 1) } // const finalPopulation = R.unfold(step, initialPopulation) // const finalPopulation = R.reduceRight(step, _ => [], R.range(0, maxSteps))(initialPopulation) const finalPopulation = step(initialPopulation, 0) const best = R.compose( R.head,
0
0
0
+ 2 other calls in file
12133 12134 12135 12136 12137 12138 12139 12140 12141 12142
* @param {Array} list The list to iterate over. * @return {*} The final, accumulated value. * @see R.reduce, R.addIndex * @example * * R.reduceRight(R.subtract, 0, [1, 2, 3, 4]) // => (1 - (2 - (3 - (4 - 0)))) = -2 * // - -2 * // / \ / \ * // 1 - 1 3 * // / \ / \
0
0
2
+ 7 other calls in file
ramda.clone is the most popular function in ramda (30311 examples)