General FizzBuzz: Difference between revisions

→‎ES6: Switch outer reduce to map + join for readability
(→‎ES6: Undo revision 272486 by Hout (talk) - This is a code snippet, not a module. ES6 modules don't share global namespace anyway. And it only evaluates twice if you have two copies in the file.)
(→‎ES6: Switch outer reduce to map + join for readability)
Line 1,349:
// fizzBuzz :: Int -> [[Int, String]] -> String
const fizzBuzz = (max, rules = defaultRules) =>
range(1, max + 1).reducemap((result, n) =>
rules.reduce((words, + (n % [factor ? '' :, word]), ''=>
result + (
rules.reduce((words, [+ (n % factor, ? '' : word]), =>''
) +|| '\n', ''
words + (n % factor ? '' : word), ''
) || .join('\n')
) + '\n', ''
).slice(0, -1)
 
console.log(fizzBuzz(20))</lang>
</lang>
 
{{Out}}