Functional programming revolves around the concepts of immutability and functions. We learned about immutability in the last chapter; we also got a glimpse of pure functions while discussing immutability. Pure functions are basically one of the many types (but probably the most important one) that functional programming has to offer.
This chapter will revolve around functions. To go into depth on functional programming, you need a strong base in functions. To get your concepts clear, we will start with ordinary Kotlin functions and then gradually move on to discuss abstract concepts on functions that functional programming defines. We will also see their implementation in Kotlin.
In this chapter, we are going to cover the following topics:
- Functions in Kotlin
- Function types
- Lambda
- High order functions
- Understanding side effects and pure functions
So, let's get started by defining functions.