How to use the splitAt function from ramda
Find comprehensive JavaScript ramda.splitAt code examples handpicked from public code repositorys.
4160 4161 4162 4163 4164 4165 4166 4167 4168 4169
* @param {Number} index The index where the array/string is split. * @param {Array|String} array The array/string to be split. * @return {Array} * @example * * R.splitAt(1, [1, 2, 3]); //=> [[1], [2, 3]] * R.splitAt(5, 'hello world'); //=> ['hello', ' world'] * R.splitAt(-1, 'foobar'); //=> ['fooba', 'r'] */ var splitAt = _curry2(function splitAt(index, array) {
0
0
0
+ 53 other calls in file
GitHub: cberube/AoC-2022
35 36 37 38 39 40 41 42 43 44
// continue to ignore the outer ring of trees. for (let y = 1; y < gridHeight - 1; y++) { for (let x = 1; x < gridWidth - 1; x++) { const currentHeight = treeGrid[toIndex(x, y)] const rowData = R.splitAt(x, getRow(y)) const columnData = R.splitAt(y, getColumn(x)) // We want to look FROM the tree TOWARDS the edge, but the // left and above arrays will be orders FROM the edge TOWARDS // the tree, so we reverse them
0
0
0
137 138 139 140 141 142 143 144 145 146
// Float -> Chromosome -> Chromosome -> (Chromosome, Chromosome) const crossover = (crossoverRate, x, y) => { const r = Math.random() * crossoverRate if (r <= crossoverRate) { const n = getRandomInt(1, Math.min(x.length, y.length) - 1) const [xStart, xEnd] = R.splitAt(n, x) const [yStart, yEnd] = R.splitAt(n, y) const xNew = [...xStart, ...yEnd] const yNew = [...yStart, ...xEnd] return (xNew, yNew)
0
0
0
+ 5 other calls in file
8 9 10 11 12 13 14 15 16 17 18 19 20
const getTargetFor = (value, pickup) => R.pipe(rotateN(value), R.without(pickup), R.head)(SORTED_CUPS) const splitAtTarget = (target, list) => R.splitAt(R.indexOf(target, list) + 1, list) const move = (cups) => { const value = R.head(cups), [pickup, rest] = R.splitAt(3, R.tail(cups)),
0
0
0
+ 5 other calls in file
ramda.clone is the most popular function in ramda (30311 examples)