In functional programming we construct programs entirely out of modular pure functions, using function composition to "combine" functions' effects to create a pipeline through which our program's data can flow through.
- Run the tests in
pipeline.test.jswith the commandnode pipeline.test.js- tests should be failing - Get the tests to pass by implementing the
pipelinefunction, which takes as arguments any number of single-argument functions and returns a single function representing their composition, i.e. a function that passes the input value through a "pipeline" of the functions.- [challenge] Implement the
pipelinefunction in one line, using thereducefunction you implemented inhigher-order/filterMapReduce.js
- [challenge] Implement the
- Compare your implementation(s) with those of your partner/group
- Run the tests in
snakeCharmer.test.jswith the commandnode snakeCharmer.test.js- tests should be failing, let's get them to pass - Fill in the
snakeToCamelfunction to make a composed function that reformats a string fromsnake_casetocamelCase. Try to break down the transformation into small functions, then use yourpipelinefunction to compose them. - Fill in the
snakeToTrainfunction to reformat a string fromsnake_casetoTrain-Case. How much of your code fromsnakeToCamelcan you reuse? - [challenge] Write more functions to translate to more cases, e.g.
PascalCase,kebab-case,SCREAMING_SNAKE_CASE,SCREAMING-TRAIN-CASE, etc... - try to use pipelining to reuse as much code as possible! - [challenge] Since our pipeline operates on single-argument functions, it will work great in combination with currying. Try to de-clutter your
snakeCharmercode by writing & using curried versions of thefilter,map, andreducefunctions - in what cases does currying help?