Play a fun functional programming game

Category: programming


Functional programming is cool and fun – at least it should be. But if I look at the definition on Wikipedia:

In computer science, functional programming is a programming paradigm—a style of building the structure and elements of computer programs—that treats computation as the evaluation of mathematical functions and avoids changing-state and mutable data.

Then I guess it does not seem that fun any more. To me, it is more like after a few transformations we can get magic output from input – cube-composer is an online little game for getting a basic sense of how map, filter, and reduce work in functional programming.

So basically it starts with some input, colored blocks and the target is another set of colored block arrangement. For example:

Game Demo

So first we do a simple reduce – combining consecutive equal columns, and then we append yello block to each column, and now we reject red blocks, and finally we transform yellow to brown blocks and we get the target arrangement.

Map-reduce paradigm is a very powerful idea – it is in fact the key idea behind the great mapreduce paper from Google. Hopefully by playing this game you can understand map and reduce concept a bit better and have fun at the same time.

Final Challenge as of 2018-02-09