const head = xs => xs[0]; const tail = xs => xs.slice(1); const add = a => b => a + b; const dot = Y(f => n => n < 1 ? '' : '.' + f(n - 1)); const factorial = Y(f => n => n < 1 ? 1 : n * f(n - 1)); const reduce = f => Y(g => y => xs => xs.length < 1 ? y : g(f(y)(head(xs)))(tail(xs))); dot(3) //> "..." factorial(4) //> 24 reduce(add)(0)([1, 2, 3]) //> 6