Pascal's triangle: Difference between revisions

m
→‎JS ES6: Updated primitives
No edit summary
m (→‎JS ES6: Updated primitives)
Line 2,626:
length: Math.floor(n - m) + 1
}, (_, i) => m + i);
 
// flip :: (a -> b -> c) -> b -> a -> c
const flip = f => (a, b) => f(b, a);
 
// foldl :: (b -> a -> b) -> b -> [a] -> b
Line 2,631 ⟶ 2,634:
 
// foldr (a -> b -> b) -> b -> [a] -> b
const foldr = (f, a, xs) => xs.reduceRight(flip(f), a);
 
// map :: (a -> b) -> [a] -> [b]
Line 2,646 ⟶ 2,649:
 
// TEST -------------------------------------------------------------------
return foldr((ax, xa) => {
const strIndent = a.indent;
return {
9,655

edits