Functional Scala: High, Higher, Higher Order Functions

Welcome to the sixth episode of Functional Scala!

This time, we’ll finally dive into one of the most powerful concepts i consistently referred to again and again within almost every previous part of this series: Higher Order Functions. Isn’t that cool? I know it’s not, since a cool name alone can’t set you on fire. I will demonstrate you some of its coolness and show you some essential aspects which induce not few voices to accuse Higher Order Functions as one of the basic principles for elegance, compactness and efficiency in Functional Programming.

So what’s a Higher Order Function then? Is there some meta-magic in it or why they are called higher ordered? Let’s develop a sense for them by firstly focusing on a common problem: Duplication of code. Let’s start by writing a simple Function which can be applied to a list of integer values, resulting into another filtered list, containing only all even values of the incoming list: Read the rest of this entry »

Posted in Scala. 10 Comments »

Functional Scala: Comprehending Comprehensions

Welcome to the fifth episode of Functional Scala!

Have you ever heard about set comprehensions? Well, if you ever took a course in mathematics, you surely have. But don’t fear if not! It’s simply a mathematical notation for specifying a set of elements by stating the properties that its members must statisfy. If this sounds too abstract to you, let’s take a look at some simple examples:

{  x  |  x ∈ N  :  x == x²  } Read the rest of this entry »

Posted in Scala. 6 Comments »

Functional Scala: Closures

Welcome to the fourth episode of Functional Scala!

This time we’ll take a closer look at those all-around highly discussed Closures and try to clear some misunderstandings about it, since there are so many discussions out there, confusing simple Functions with Closures. In the first place, Closures are simply Functions featuring some special characteristics (which we’ll gonna talking about) turning them into, well … Closures. Read the rest of this entry »

Posted in Scala. 24 Comments »

Functional Scala: Functions as Objects as Functions

Welcome back to the third episode of Functional Scala!
This time i want to take you for a short ride to some Scala internals and open the curtain for that arcane Function types i talked about the last episode. That said, this episode is more about some Specialité de Scala rather than about Functional Programming in general. Read the rest of this entry »

Posted in Scala. 17 Comments »