Filter a NSArray Using a Block

A quick post just to point out a minor thing.

If you have ever had the need of filtering an array in Objective-C you know that Apple provides a method called filteredArrayUsingPredicate:, that takes a NSPredicate and returns a NSArray containing only the objects from the original array that satisfy that predicate.

I personally find the NSPredicate format really annoying and error prone.

Obj-C: Infer Types Like a Man, Man

The Objective-C type system, in brief

From a type system point of view Objective-C can be seen as hybrid language: it both allows dynamic typing, therefore achieving a great flexibility, and static typing, turning the compiler into a precious ally.

When coding you can explicitly declare the types of all your variables or decide to use the keywork id, which - in short - is a sort of a hint to the compiler telling him: ”Look, I know what I’m doing. Just trust me and everything will work out just fine.”.

Sometimes using id comes in very handy, for instance id is the type of any object hold by a generic container (as NSArray) eliminating altogether the need for templates or generics (like you see in C++ or Java).

Haskell Data Declaration Constraints, the Right Way

Recently I’ve been using the Haskell language to implement the solutions to the Coursera’s Algorithms 2 online course.

The idea of using Haskell came talking with Mario who was already using it for the very same purpose.

In such context Mario started developing a purely functional Union-Find data structure an he eventually run into an interesting problem concerning algebraic data types that inspired this post.

The Root of All Tex

Hi everyone!

Recently we talked about how to set-up a delightful working environment for LaTeX using Sublime Text 2.

Today I want to share with you a trick that will help you while dealing with multi-part LaTeX documents using the \input or the \include commands.

LaTeX Is Now Sublime

Hi everyone!

I can safely guess that many of you use or have used LaTeX, the beautiful markup language by Leslie Lamport.

If you don’t and you have some aesthetic taste I suggest you to check it out and stop producing ugly Word documents. If instead you know what I’m talking about, I’d like to share with you all my LaTeX configuration, which makes use of the awesome editor Sublime Text 2 and its plug-in LaTeXTools.

Hello, World!

First post on this blog, I don’t even know if anybody will read this at all. Anyway, who cares! This blog is meant as a resource where to find solutions to real life problems, mostly related to the programming world. (yeah, exactly, like thousands of other blogs out there! One more shouldn’t harm too much, after all…) Before going on I’ve to warn you reader: this is a geek-nerd-whatever blog, so if you are reading this and you don’t even know what a programming language is – why the heck are you here in the first place?! – I apologize but I have to suggest to spend your spare time somewhere else: youtube.com, facebook.com, youporn.com are good candidates).