Published
Edited
Jul 29, 2020
7 stars
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
zero = f => x => x
Insert cell
one = f => x => f(x)
Insert cell
two = f => x => f(f(x))
Insert cell
three = f => x => f(f(f(x)));
Insert cell
Insert cell
toNumber = n => n(i => i+1)(0);
Insert cell
toNumber(two)
Insert cell
Insert cell
Insert cell
Insert cell
add = n => m => f => x => m(f)(n(f)(x))
Insert cell
four = add(one)(three)
Insert cell
toNumber(four)
Insert cell
Insert cell
Insert cell
mul = n => m => f => x => m(n(f))(x)
Insert cell
toNumber(mul(two)(three))
Insert cell
Insert cell
pow = n => m => m(n)
Insert cell
toNumber(pow(two)(three))
Insert cell
Insert cell
answer = add(two)(mul(four)(mul(two)(add(four)(one))))
Insert cell
toNumber(answer)
Insert cell
Insert cell
Insert cell
ifThenElse = bool => thenDo => elseDo => bool(thenDo)(elseDo)
Insert cell
troo = thenDo => elseDo => thenDo
Insert cell
falz = thenDo => elseDo => elseDo
Insert cell
tired = troo
Insert cell
coffeesToday = ifThenElse(tired)(three)(one)
Insert cell
toNumber(coffeesToday)
Insert cell
Insert cell
toBoolean = bool => bool(true)(false)
Insert cell
toBoolean(troo)
Insert cell
Insert cell
not = bool => thenDo => elseDo => bool(elseDo)(thenDo)
Insert cell
toBoolean(not(troo))
Insert cell
Insert cell
or = A => B => A(A)(B)
Insert cell
toBoolean(or(troo)(falz))
Insert cell
and = A => B => A(B)(A)
Insert cell
toBoolean(and(troo)(falz))
Insert cell
Insert cell
Insert cell
makePair = left => right => f => f(left)(right)
Insert cell
getLeft = pair => pair(troo)
Insert cell
getRight = pair => pair(falz)
Insert cell
toNumber(getLeft(makePair(two)(three)))
Insert cell
Insert cell
Insert cell
isEmpty = getLeft
Insert cell
nil = makePair(troo)(troo)
Insert cell
toBoolean(isEmpty(nil))
Insert cell
Insert cell
prepend = item => list => makePair(falz)(makePair(item)(list))
Insert cell
singleItemList = prepend(one)(nil); // (falz, (1, nil))
Insert cell
multiItemList = prepend(three)(prepend(two)(singleItemList)) // (falz, (3,(2,(1,nil))))
Insert cell
Insert cell
Insert cell
tail = list => getRight(getRight(list))
Insert cell
toNumber(head(tail(multiItemList)))
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
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