Clojure sequential data types for Python programmers

I have been working with Python for more than fifteen years and I developed very big systems with this language, learning to know and love both its power and its weaknesses, admiring its gorgeous object-oriented system and exploring some of its darkest corners.

Despite being so committed to this language (both for personal choices and for business reasons) I never stopped learning new languages, trying to get a clear picture of new (or old) paradigms, to explore new solutions to old problems and in general to get my mind open.

Unfortunately introducing a new language in your business is always very risky, expensive and many times not a decision of yours only. You are writing software that other may have to maintain, so either you evangelize your team and persuade other to join you or you will be forced to stay with the languages shared by them. This is not bad in itself, but sometimes it is a big obstacle for the adoption of a new language.

One of the languages I fell in love (but ... more

Python decorators: metaprogramming with style

This post is the result of a lot of personal research on Python decorators, meta- and functional programming. I want however to thank Bruce Eckel and the people behind the open source book "Python 3 Patterns, Recipes and Idioms" for a lot of precious information on the subject. See the Resources section at the end of the post to check their work.

Is Python functional?

Well, no. Python is a strong object-oriented programming language and is not really going to mix OOP and functional like, for example, Scala (which is a very good language, by the way).

However, Python provides some features taken from functional programming. Generators and iterators are one of them, and Python is not the only non pure functional programming language to have them in their toolbox.

Perhaps the most distinguishing feature of functional ... more

99 Scala Problems 11 - Modified run-length encoding

The problem

P11 (*) Modified run-length encoding. Modify the result of problem P10 in such a way that if an element has no duplicates it is simply copied into the result list. Only elements with duplicates are transferred as (N, E) terms.


scala> encodeModified(List('a, 'a, 'a, 'a, 'b, 'c, 'c, 'a, ... more

99 Scala Problems 10 - Run-length encoding of a list.

The problem

P10 (*) Run-length encoding of a list. Use the result of problem P09 to implement the so-called run-length encoding data compression method. Consecutive duplicates of elements are encoded as tuples (N, E) where N is the number of duplicates of the element E.


scala> encode(List('a, 'a, 'a, 'a, 'b, 'c, 'c, 'a, ... more

99 Scala Problems Index

I decided to learn Scala. I looked for some good exercises for Scala programmers and found S-99: Ninety-Nine Scala Problems, and since writing about things helps me learning them I am going to write a post for each problem I manage to solve.

The official site provides solutions for the problems, so my solutions will obviously be influenced by those, when not the same.

CAVEAT: I am a beginner so what I state in the following posts may be inaccurate and sometimes wrong. Please submit an issue on the blog GitHub issues page.

This is the index of the problems I already discussed. I kept the original title and difficulty ranking (asterisks)