Published
Edited
Nov 29, 2021
1 fork
16 stars
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
function f(x) {
return 2 * x + 3;
}
Insert cell
f(5)
Insert cell
f(2)
Insert cell
f(1729)
Insert cell
Insert cell
Insert cell
x => 2*x+3
Insert cell
Insert cell
my_function = x => 2*x+3
Insert cell
my_function(5)
Insert cell
Insert cell
pythagoras = a => b => a*a + b*b
Insert cell
pythagoras(3)(4)
Insert cell
Insert cell
Insert cell
LEFT = a => b => a
Insert cell
LEFT('✅')('❌')
Insert cell
Insert cell
Insert cell
RIGHT('✅')('❌')
Insert cell
Insert cell
LEFT('On')('Off')
Insert cell
RIGHT('On')('Off')
Insert cell
Insert cell
Insert cell
TRUE = x => y => x
Insert cell
Insert cell
FALSE = x => y => y
Insert cell
Insert cell
Insert cell
Insert cell
NOT = x => x(FALSE)(TRUE)
Insert cell
NOT(TRUE)('✅')('❌')
Insert cell
NOT(FALSE)('✅')('❌')
Insert cell
Insert cell
Insert cell
AND = x => y => x(y)(x)
Insert cell
Insert cell
AND(TRUE)(TRUE)('✅')('❌')
Insert cell
AND(TRUE)(FALSE)('✅')('❌')
Insert cell
AND(FALSE)(TRUE)('✅')('❌')
Insert cell
AND(FALSE)(FALSE)('✅')('❌')
Insert cell
Insert cell
OR = x => y => x(x)(y)
Insert cell
OR(TRUE)(TRUE)('✅')('❌')
Insert cell
OR(TRUE)(FALSE)('✅')('❌')
Insert cell
OR(FALSE)(TRUE)('✅')('❌')
Insert cell
OR(FALSE)(FALSE)('✅')('❌')
Insert cell
Insert cell
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
THREE
Insert cell
Insert cell
TALLY = x => x+1
Insert cell
TALLY(TALLY(TALLY(0)))
Insert cell
THREE(TALLY)(0)
Insert cell
Insert cell
STAR = x => x+'⭐'
Insert cell
THREE(STAR)('')
Insert cell
FIB = t => t.concat(t.at(-1) + t.at(-2))
Insert cell
THREE(FIB)([1, 1])
Insert cell
Insert cell
FOUR = f => x => f(f(f(f(x))))
Insert cell
FIVE = f => x => f(f(f(f(f(x)))))
Insert cell
Insert cell
ZERO = f => x => x
Insert cell
ZERO(TALLY)(0)
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
SUCC = n => f => x => f(n(f)(x))
Insert cell
SUCC(TWO)(TALLY)(0)
Insert cell
Insert cell
Insert cell
ADD = x => y => y(SUCC)(x)
Insert cell
ADD(FOUR)(FIVE)(TALLY)(0) // remember we still need to evaluate our number to see the result
Insert cell
Insert cell
MUL = x => y => f => y(x(f))
Insert cell
MUL(FIVE)(TWO)(TALLY)(0)
Insert cell
Insert cell
EXP = x => y => y(x)
Insert cell
EXP(TWO)(FIVE)(TALLY)(0)
Insert cell
Insert cell
Insert cell
PAIR = a => b => f => f(a)(b)
Insert cell
my_tuple = PAIR(2)(3)
Insert cell
Insert cell
my_tuple(TRUE)
Insert cell
my_tuple(FALSE)
Insert cell
Insert cell
FIRST = p => p(TRUE)
Insert cell
SECOND = p => p(FALSE)
Insert cell
FIRST(my_tuple)
Insert cell
SECOND(my_tuple)
Insert cell
Insert cell
my_list = PAIR(2)(PAIR(3)(4))
Insert cell
SECOND(SECOND(my_list))
Insert cell
Insert cell
PHI = p => PAIR(SUCC(FIRST(p)))(FIRST(p))
Insert cell
Insert cell
phi_test = FOUR(PHI)(PAIR(ZERO)(ZERO))
Insert cell
FIRST(phi_test)(TALLY)(0)
Insert cell
SECOND(phi_test)(TALLY)(0)
Insert cell
Insert cell
PRED = n => SECOND(n(PHI)(PAIR(ZERO)(ZERO)))
Insert cell
Insert cell
big_number = EXP(FOUR)(FIVE)
Insert cell
PRED(big_number)(TALLY)(0)
Insert cell
Insert cell
SUB = x => y => y(PRED)(x)
Insert cell
SUB(FIVE)(TWO)(TALLY)(0)
Insert cell
Insert cell
ISZERO = n => n(f=>FALSE)(TRUE)
Insert cell
ISZERO(ZERO)('T')('F')
Insert cell
ISZERO(TWO)('T')('F')
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
function factorial(x){
if (x === 0) {return 1}
else{
return x * factorial(x-1)
}
}
Insert cell
factorial(5)
Insert cell
Insert cell
fact_anon = x => x == 0 ? 1 : x * fact_anon(x-1)
Insert cell
Insert cell
fact = (f => x => x == 0 ? 1 : x * f(f)(x-1))(f => x => x == 0 ? 1 : x * f(f)(x-1))
Insert cell
Insert cell
fact(5)
Insert cell
Insert cell
ONE(Math.sqrt)(1729)
Insert cell
TWO(Math.sqrt)(1729)
Insert cell
THREE(Math.sqrt)(1729)
Insert cell
Insert cell
big_number(Math.sqrt)(1729)
Insert cell
Insert cell
Insert cell
Y = f => (x => f(x(x)))(x => f(x(x)))
Insert cell
Insert cell
R = f => x => x == 0 ? 1 : x * f(x-1)
Insert cell
Insert cell
factorial_Y = Y(R)
Insert cell
Insert cell
Insert cell
Z = f => (x => f(v => x(x)(v)))(x => f(v => x(x)(v)))
Insert cell
factorial_Z = Z(R)
Insert cell
factorial_Z(5)
Insert cell
Insert cell
Insert cell
Fibonacci = f => x => x <= 1 ? x : f(x-1) + f(x-2)
Insert cell
Fib_Z = Z(Fibonacci)
Insert cell
Fib_Z(10)
Insert cell
Insert cell
Insert cell
Insert cell
R_lambda = f => x => ISZERO (x) ( ONE ) ( MUL (x) ( f( PRED(x) ) ) )
Insert cell
Insert cell
FACT = Z(R_lambda)
Insert cell
Insert cell
FACT(FIVE)(TALLY)(0)
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