Published
Edited
Jul 6, 2021
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
dbg = (x) => log(x) || x
Insert cell
debug = curry((title,x) => log(title) || x)
Insert cell
dbgt = curry((title,x) => log(title,x) || x)
Insert cell
mul2 = multiply(2)
Insert cell
add2 = add(2)
Insert cell
div2 = divide(__,2)
Insert cell
Insert cell
Insert cell
tm = (x) => log('mul2',x)
Insert cell
ta = (x) => log('add2',x)
Insert cell
td = (x) => log('div2',x)
Insert cell
ti = (x) => log('\ninput',x)
Insert cell
ftap = pipe(tap(ti),mul2,tap(tm),add2,tap(ta),div2,tap(td))
Insert cell
ftap(3) // input 3 mul2 6 add2 8 div2 4
Insert cell
Insert cell
f = pipe(debug('\npipe'),dbg,mul2,dbg,add2,dbg,div2,dbg)
Insert cell
f(3)
Insert cell
ft = pipe(dbgt('\npipe'), mul2,dbgt('*2'), add2,dbgt('+2'), div2,dbgt('/2'))
Insert cell
ft(3) // pipe 3 *2 6 +2 8 /2 4
Insert cell
Insert cell
g = debug('\ncompose',compose(dbg,div2,dbg,add2,dbg,mul2,dbg))
Insert cell
g(3) // compose 3 6 8 4
Insert cell
Insert cell
md`* (-) many parens`
Insert cell
div2(add2(mul2(3)))
Insert cell
h = (x) => dbg(div2(dbg(add2(dbg(mul2(dbg(debug('nested',x))))))))
Insert cell
h(3) // nested 3 6 8 4
Insert cell
sq = map((x) => x*x)
Insert cell
dbg(sq(dbg([1,2,3,4,5]))) // [1 2 3 4 5] [1 4 9 16 25]
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