Public
Edited
Jan 21
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
size = 4 * 9 * (n + 5) + margin
Insert cell
margin = 9*14
Insert cell
plot =
({ title, subtitle } = {}) =>
(data) =>
Plot.plot({
title,
subtitle,
style: `transform: rotate(${45}deg); background: transparent;`,
color: {
scheme: "cubehelix",
range: [.4, 1],
// reverse: true,
},
x: { axis: null },
y: { axis: null },
marks: [
Plot.cell(data, {
x: "x",
y: "y",
fill: d => d.consonance || "none",
stroke: "grey"
}),
Plot.text(data, {
x: "x",
y: "y",
text: "r",
fontSize: "larger",
rotate: -45,
})
],
padding: 0,
marginTop: margin,
marginLeft: margin,
marginRight: margin,
marginBottom: margin,
width: size,
height: size,
})
Insert cell
viewof vuur = Inputs.table(
matrix(
(x, y) => ({
x,
y,
consonance: cons(x + 1, y + 1),
r: F(x + 1, y + 1).toRatio(),
})
),
{
width:36*12,
format: {
consonance: d => d.toFixed(2)
}
}
)
Insert cell
cons = (a, b) => {
const {n, d} = Fraction(a, b);
const consonance = ((k) => (p, q) => 1 / (p + q) ** k)(1);
return 2 * consonance(Number(n), Number(d));
}
Insert cell
matrix = tab(n, n)
Insert cell
tab =
(rows, cols) =>
(ƒ) =>
range(rows)(
(_, y) =>
range(cols)(
(_, x) =>
ƒ(x, y)
)
)
.flat()
Insert cell
range = (length) => (ƒ) => Array.from({ length }, ƒ)
Insert cell
Fraction = require("fraction.js")
Insert cell
F = (...f) => Object.assign(
Fraction(f),
{
toRatio: function () {return `${this.n}/${this.d}`},
// lcm,
// cd: (list) => {const n = lcm(list).n; return list.map(objectify(n));}
}
)
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