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

Thinking recursively

The key to solving problems recursively is assuming that you already have a function that does whatever you need, and just call it normally. (Doesn't this sound weird? Actually, it is quite appropriate: to solve a problem with recursion, you must first solve the problem...) On the other hand, if you try to work out in your head how the recursive calls work and attempt to follow the flow in your mind, you'll probably just get lost. So, what you need to do is:

  1. Assume you already have an appropriate function to solve your problem.
  2. Then, see how the big problem can be solved by solving one (or more) smaller problems.
  3. Solve those problems by using the imagined function from step 1.
  4. Decide what are your base cases, simple ...
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