Public
Edited
Jun 13, 2024
1 fork
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
generic = (f) => (left, right) => join(left, right, f)
Insert cell
class Arithmetic {
static ["+"] = Propagator.lift(handleNothing(generic(Num["+"])));
static ["-"] = Propagator.lift(handleNothing(generic(Num["-"])));
static ["*"] = Propagator.lift(handleNothing(generic(Num["*"])));
static ["/"] = Propagator.lift(handleNothing(generic(Num["/"])));

static sq = Propagator.lift(handleNothing(generic(Num.sq)));
static sqrt = Propagator.lift(handleNothing(generic(Num.sqrt)));
}
Insert cell
Insert cell
Insert cell
Insert cell
function fahrenheitToCelsius(f, c) {
const thirtyTwo = Cell.new();
const fMin32 = Cell.new();
const five = Cell.new();
const cMult9 = Cell.new();
const nine = Cell.new();

constant(32)(thirtyTwo);
constant(5)(five);
constant(9)(nine);
Arithmetic["-"](f, thirtyTwo, fMin32);
Arithmetic["*"](fMin32, five, cMult9);
Arithmetic["/"](cMult9, nine, c);
}
Insert cell
f = Cell.new()
Insert cell
c = Cell.new()
Insert cell
Insert cell
fahrenheitToCelsius(f, c)
Insert cell
write(f, 77)
Insert cell
Insert cell
read(c)
Insert cell
Insert cell
Insert cell
sum = (x, y, z) => {
Arithmetic["+"](x, y, z);
Arithmetic["-"](z, x, y);
Arithmetic["-"](z, y, x);
}
Insert cell
Insert cell
Insert cell
function fahrenheit_celcius(f, c) {
const thirtyTwo = Cell.new();
const fMin32 = Cell.new();
const five = Cell.new();
const cMult9 = Cell.new();
const nine = Cell.new();

constant(32)(thirtyTwo);
constant(5)(five);
constant(9)(nine);

sum(thirtyTwo, fMin32, f);
product(fMin32, five, cMult9);
product(c, nine, cMult9);
}
Insert cell
f2 = Cell.new()
Insert cell
c2 = Cell.new()
Insert cell
fahrenheit_celcius(f2, c2)
Insert cell
write(c2, 25)
Insert cell
read(f2)
Insert cell
Insert cell
Insert cell
Insert cell
fallDuraction = (t, h) => {
const g = Cell.new();
const oneHalf = Cell.new();
const tQuad = Cell.new();
const gtQaud = Cell.new();

constant(range(9.789, 9.832))(g);
constant(range(1 / 2, 1 / 2))(oneHalf);
debugger;
quadratic(t, tQuad);
product(g, tQuad, gtQaud);
product(oneHalf, gtQaud, h);
}
Insert cell
Insert cell
fallTime = Cell.new()
Insert cell
buildingHeight = Cell.new()
Insert cell
fallDuraction(fallTime, buildingHeight)
Insert cell
write(fallTime, range(2.9, 3.1))
Insert cell
buildingHeight.content
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