How to use the splitWhenever function from ramda
Find comprehensive JavaScript ramda.splitWhenever code examples handpicked from public code repositorys.
GitHub: VesaLahd/aoc2022
78 79 80 81 82 83 84 85 86 87 88 89
R.range(0,R.length(monkeys)) )) const monkeys1 = R.compose( R.map(parseMonkey(true)), R.splitWhenever(R.isEmpty) )(content) const monkeys2 = R.compose( R.map(parseMonkey(false)),
0
0
0
+ 7 other calls in file
GitHub: kellyi/advent
5 6 7 8 9 10 11 12 13 14 15
const elves = R.pipe( R.partialRight(fs.readFileSync, ["utf8"]), R.trim, R.split('\n'), R.map(parseInt), R.splitWhenever(R.equals(NaN)), )(DATA); // part 1 R.pipe(
0
0
0
GitHub: cberube/AoC-2022
52 53 54 55 56 57 58 59 60 61
const lines = data.split('\n') // A lot of focus on parsing slightly bad input formats // in this year's puzzles... // Let's split the list into paragraphs for each monkey const monkeyDataList = R.splitWhenever(line => line.length < 1, lines) // The first line that identifies the monkey is unimportant // so let's just throw it away const monkeyList = monkeyDataList.map(parseMonkeyData)
0
0
0
6 7 8 9 10 11 12 13 14 15 16 17 18
}); // -------------------------------------------- function parse(lines) { return R.splitWhenever(x => x.length < 1, lines).map(x => x.map(y => JSON.parse(y))); } // --------------------------------------------
0
0
0
6 7 8 9 10 11 12 13 14 15 16 17
}); // -------------------------------------------- function parse(lines) { const s1 = R.splitWhenever(R.isEmpty, lines); const s2 = s1.map(x => ({ items: x[1].split(': ')[1].split(', ').map(Number), op: R.takeLast(2, x[2].split(' ')), test: Number(R.last(x[3].split(' '))),
0
0
0
10 11 12 13 14 15 16 17 18 19 20 21 22
function parse(lines) { const step1 = R.flatten(lines.map(x => R.startsWith('$', x) ? ['$', R.tail(x.split(' ')).join(' ')] : x)); U.log('step 1', step1); const step2 = R.splitWhenever(R.startsWith('$'), step1); U.log('step 2', step2); return step2.map(c => {
0
0
0
ramda.clone is the most popular function in ramda (30311 examples)