The most interesting property of Functional Programming is composition. The Option type allows composing small functions to form a bigger function. Si

Chain functions using Option type – Functional Programming

submited by
Style Pass
2021-07-26 18:00:12

The most interesting property of Functional Programming is composition. The Option type allows composing small functions to form a bigger function. Since every function is pure, we can test every single function in isolation. If all the basic functions are correct, we can be (almost) sure that a bigger and more complex function composed from these building blocks is also correct!

I highly encourage you to read the previous article in the series. Many of the basic concepts have been explained in the previous article, so you may have trouble understand this post if you do not read the previous one.

You want to go shopping. Your first option is going to the Shopping Center. Nonetheless, if the Shopping Center is closed, you will go to the Local Market, which is always open.

You want to buy exactly one Banana (🍌), one Apple (🍎), and one Pear (🍐). If any one of these fruits is missing, you will leave empty handed and not buy anything.

Leave a Comment