In my research, I found another gem by Braithwaite,
turn a series of nested function calls into an iteration–removing the limits on composition. The
I’ll demonstrate this by summing integers less than n instead of multiplying them.
For instance, my build of Chrome can provide an answer for
sumInts(15634) but throws a
15635 while Safari can go as high as
sumInts(34944). When I write the same algorithm as a Stack,
it solves even higher numbers (and is only slightly less elegant, IMO).
So, what do you add to a trampolining, singly-linked, stack implementation? Promises. Promises represent one of the most paradigm-shifting concepts I ever learned in this language–I can’t leave them out.
Check out Stack.js, tell me what you think and what you might build with it.