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

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