Published
Edited
Oct 10, 2018
Insert cell
Insert cell
Insert cell
// Usage: Y(sumFactory)([1,2,3])
function Y(f) {
return (
m => x => f(m(m))(x)
)(
m => x => f(m(m))(x)
);
}
Insert cell
function sum([head, ...tail]) {
if (!tail.length) return head;
return head + sum(tail);
}
Insert cell
function sumFactory(sum) {
return ([head, ...tail]) => {
if (!tail.length) return head;
return head + sum(tail);
};
}
Insert cell
function factorialFactory(factorial) {
return num => {
if (num === 0) return 1;
return num * factorial(num - 1);
};
}
Insert cell

Purpose-built for displays of data

Observable is your go-to platform for exploring data and creating expressive data visualizations. Use reactive JavaScript notebooks for prototyping and a collaborative canvas for visual data exploration and dashboard creation.
Learn more