begin in ES6

In order to write a begin lookalike in ES6, we can take advantage of the fact that in JavaScript arguments are evaluated from left to right. This leads to: const begin = (...args) => args[args.length - 1]; We can therefore replicate SICP's make-withdraw procedure as: const makeWithdraw = bal =>…

let in ES6

A possible way of expressing Scheme let expressions, such as (let ((x 3) (y 5)) (+ x y)) is to use ES6 default parameters: ((x = 3, y = 5) => x + y)() It is possible to go one step further by defining an auxiliary let_ function as: const let_ = f => f(…