Functional programming includes a lot about functions. There are different kinds of functions in programming, for example, pure functions. A pure function depends only on its input to compute the output. Let's try the following example to make use of functions:
scala> val addThem = (x: Int, y: Int) => x + y + 1 addThem: (Int, Int) => Int = <function2> scala> addThem(3,4) res2: Int = 8
As long as the function lives, it will always give the result
8 given the input (
3,4).Take a look at the following example of a pure function:
The functions worked on the input and produced the output, without changing any state. ...