Pascal's triangle: Difference between revisions

m
→‎JS ES6: ( clearer formatting/commenting of main function )
(→‎JS ES6: Updated primitives)
m (→‎JS ES6: ( clearer formatting/commenting of main function ))
Line 2,512:
const pascal = n =>
foldl(a => {
const lstPreviousRowxs = a.slice(-1)[0]; // Previous row
return append(a, [
zipWith((a, b) => a + b, append([0], lstPreviousRow),
append(lstPreviousRowa, [0])b) => a + b,
append([0], xs),
append(xs, [0])
)
]);
}, [
[1] // Initial seed row
], enumFromTo(1, n - 1));
 
 
// GENERIC FUNCTIONS ------------------------------------------------------
9,659

edits