Public
Edited
Apr 30, 2023
1 star
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
cycle = list => {
const go = ([x, ...xs]) => x ? new Stream(x, () => go(xs)) : go(list);
return go(list);
};
Insert cell
Insert cell
nat = {
const _nat = new Stream(0, () => _nat.map(R.add(1)));
return _nat;
}
Insert cell
Insert cell
primes = {
const go = n => new Stream(n, () => go(n + 1).filter(x => x % n !== 0));
return go(2);
}
Insert cell
Insert cell
fib = {
const add = R.lift(R.add);
// fib = [0, ...(fib + [1, ...fib])]
const _fib = new Stream(0, () => add(_fib, new Stream(1, () => _fib)));
return _fib;
}
Insert cell
(ratio (fib)).at (20)
Insert cell
R.take (20) (R.lift (R.multiply) (nat) (primes))
Insert cell
{
const zip = R.lift(R.pair);
const zipped = R.take (5) (zip (nat) (primes));
return zipped.map(R.toString);
}
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Array.from(take(primes, 10));
Insert cell
interleave(nat, Stream.of('f')).take(20)
Insert cell
{
let last = null;
for (const p of primes) {
if (last && p - last === 20) {
return [last, p];
}
last = p;
}
}
Insert cell
Insert cell

One platform to build and deploy the best data apps

Experiment and prototype by building visualizations in live JavaScript notebooks. Collaborate with your team and decide which concepts to build out.
Use Observable Framework to build data apps locally. Use data loaders to build in any language or library, including Python, SQL, and R.
Seamlessly deploy to Observable. Test before you ship, use automatic deploy-on-commit, and ensure your projects are always up-to-date.
Learn more