Skip to content

alejandrosobko/recursive-javascript

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Recursive javascript

Common functions implemented using recursion


Implemented:

  • map
  • filter
  • flatten
  • reverse

How is the idea?

I tried to follow the haskell way, which is basically:

  • base case
  • recursive case

So, almost always we'll have:

  • empty list
  • list with elements

(flatten is a special case, take a look at the file 😉 )

For empty list, we don't do anything. For the case of the list with elements, we separate into first element and the rest. We do something to the first element, and call the recursion to complete rest. And voila!

Map explained

Suggestions?

Please create an issue!

About

Common functions implemented using recursion in Javascript

Topics

Resources

Stars

Watchers

Forks

Packages

No packages published