Combinators
Wikipedia says the following about combinators:
"A Combinator is a higher-order function that uses only function application and earlier defined Combinators to define a result from its arguments."
As well as this definition, we could also say that a combinator is a closed lambda expression. We have already seen lambda applications in several places and defined them. A lambda is nothing more than an anonymous definition of any function. For example, when you pass an expression to our beloved foreach
method, you pass it in the form of a lambda expression. Take a look at the following:
val brands = List(Brand("Toyota", List(Car("Corolla", "Toyota"))), Brand("Honda", List(Car("Accord", "Honda"))), Brand("Tesla", List(Car("Model S", "Tesla"), Car("Model 3", "Tesla"), Car("Model X", "Tesla"), Car("New Model", "Tesla")))) brands...