Skip to content

Instantly share code, notes, and snippets.

@kat0h
Created May 26, 2024 04:28
Show Gist options
  • Save kat0h/317d456d79e505c9a84844050348f664 to your computer and use it in GitHub Desktop.
Save kat0h/317d456d79e505c9a84844050348f664 to your computer and use it in GitHub Desktop.
FizzBuzz
const z=a=>(b=>a(c=>b(b)(c)))(b=>a(c=>b(b)(c)))
const r=n=>(m=>z(x=>i=>i==m?[]:[i,x(i+1)]))(n)(0)
const map=f=>l=>z(x=>m=>m[1].length==0?[f(m[0]),[]]:[f(m[0]),x(m[1])])(l)
const fizzbuzz=x=>map(i=>i%15?i%3?i%5?i:'Buzz':'Fizz':'FizzBuzz')(r(x))
console.log(fizzbuzz(100).flat(1/0))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment