Skip to Content
Mastering JavaScript Functional Programming
book

Mastering JavaScript Functional Programming

by Federico Kereki
November 2017
Intermediate to advanced
386 pages
9h 22m
English
Packt Publishing
Content preview from Mastering JavaScript Functional Programming

Recursion elimination

There's yet one other possibility you might want to explore, but that falls beyond the realm of FP, and rather into algorithm design. It's a computer science fact that any algorithm that is implemented using recursion has an equivalent version that doesn't use recursion at all and rather depends on a stack. There are ways to systematically transform recursive algorithms into iterative ones, so if you run out of all options (meaning: not even continuations or thunks help you) then you'd have a final opportunity, by replacing all recursion with iteration. We won't be getting into it --as I said, this elimination has little to do with FP-- but it's important to know that the tool exists and you might be able to use it. ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Mastering JavaScript Functional Programming - Second Edition

Mastering JavaScript Functional Programming - Second Edition

Federico Kereki

Publisher Resources

ISBN: 9781787287440Supplemental Content