The aim of this repository is to help you get used to the functional programming style. It is a collection of exercises, with automatic tests that will check your solutions. It does not explain functional concepts. It is also introductory, so advanced topics won't be covered.
The exercises can be solved using TypeScript or JavaScript (but I strongly recommend you to use TypeScript).
You will find the exercises here.
If you want to start with functional programming and you know at least a little bit of JavaScript or TypeScript, then yes!
- Clone this repository.
- Open the directory with your code editor (project settings for Visual Studio Code are included).
- Install the dependencies (
npm i
in the console). - Run the tests.
- Solve the exercises following the rules.
You can run all the tests with npm t
or run an utilitary tool (npm run learn
or ./learn
) to just run the tests for the exercise you are interested in (recommended option).
It is really important to follow "the rules" when solving the exercises. They are there to help you solve the problems in a "functional way".
You will find the exercises here.
You can find the exercise's tests into src/exercises
directory. They are sorted in the same way than in the exercises page. To solve one exercise, you should create a file next to the test file with the same name, but without the .test
part. The first exercise (id
) is already solved as an example. In that file you should define the function that solves the problem and export
it. If it's well done, the tests should pass for that exercise.
For some exercises, you can reuse the solutions you've already done. You can (and should) also use the functions from @utils
.
Even though I recommend to use TypeScript, you can solve the exercises using JavaScript. Just use the .js
extension instead of the .ts
one for your solutions. Also, remember to set the property you want to export to module.exports
. For instance, the first exercise would be like this solved with JavaScript (into a src/exercises/01-id/id.js
file):
const id = x => x;
module.exports = {
id
};
There is a collection of utility funtions called "@utils". You can import
them by doing (for example):
import { add } from `@utils`;
The functions there are all curried. You can find the source code of them at src/utils
directory.
The solutions to the exercises are uploaded to the solutions
branch, you can take a peek to them if you wish (though I recommend you to try solving the problems by yourself first).
All the contributions (issues reporting, PRs, difussion, etc.) will be welcome.