Egghead Prof Frisby
From the first note in the notebook:
Create linear data flow with container style types
First rewrites an imperative style text manipulation with composable functions. Instead of a new line for each step, one functions embeds the next. So five lines becomes one line, but it's not really better.
##The Box
If we put the String
in a Box
which for now is an Array
([str]
) we can chain off the actions from this array:
const nextCharForNumberString = str =>
[str]
.map(s => s.trim())
.map(..)
.map(//another step...)
The great thing about this, is that each expression (.map(s => s.trim())
) is contained in its own environment.
map
is composition
It takes an input, runs a function inside it, then passes the result to the next map
.
###Defining our own Box
It will do the same thing as the Array.map
.