Let's break this down:
const _fa = fa(y => y)
// _fa = x => (y => y)(x + "a")
To avoid confusing the two x
let's name it as x1
// _fa = x1 => (y => y)(x1 + "a")
Now fb
would be:
// fb = next => x2 => next(x2 + "b")
If we call fb
with fa(y => y)
(ie. _fa
), we substitute next
with _fa
:
_fb = fb(fa(y => y))
// _fb = x2 => (x1 => (y => y)(x1 + "a"))(x2 + "b")
Now lets evaluate _fb
with the argument x2 = 'x'
:
// _fb = (x1 => (y => y)(x1 + "a"))("x" + "b")
// _fb = (x1 => (y => y)(x1 + "a"))("xb")
Notice how x1 => (y => y)(x1 + "a")
can be simplified to x1 => x1 + "a"
. Now we have:
// _fb = (x1 => x1 + "a")("xb")
Now let's evaluate this function (x1 => x1 + "a")
with argument x1 = "xb"
// _fb = "xb" + "a"
// _fb = "xba"