Public
Edited
Jul 10, 2023
Insert cell
Insert cell
input = {
// let's start by imagining that we're only going to have a 9-bit wide input; eventually we'll bump it up to 255 (or more?) but for now we just want to demonstrate. This is our input buffer
const input = 1n << 4n;
// here's how you can output binary strings:
console.log(input.toString(2));
return input;
}
Insert cell
table = {
// each rule is an 8-bit integer representing the transition rule for a 3-bit segment of the input.
// I'm not sure how it is supposed to work, but I'm guessing it's supposed to represent the possibilities
// in a lexicographically-ordered permutation of 3 bits: 000, 001, 010, 011, 100, 101, 110, 111
// (or is it reversed by convention?)
const rule = 30n;
// I'm sure there's a clever way to build this table, but for a moment, let's be dumb. Anything non-zero means true
const table = new Map();
table.set(0n, rule & 128n);
table.set(1n, rule & 64n);
table.set(2n, rule & 32n);
table.set(3n, rule & 16n);
table.set(4n, rule & 8n);
table.set(5n, rule & 4n);
table.set(6n, rule & 2n);
table.set(7n, rule & 1n);

return table;
}
Insert cell
Insert cell
next(input, table, 9n)
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