Skip to main content

Scala Coding Exercise - A Recursive Implementation of an Immutable List

I recently got to code a list as an interview coding exercise from one of the FAANGs. I thought that it might be a good idea to post it there for future reference.

I went for a recursive and immutable implementation. It's quite naive and I would certainly not use it in production, but as an exercise it was fun writing it due to its elegance.

If you look at the list implementation in Scala 2.12, they went for an imperative solution for most methods... Elegance sometimes comes at too high a price in terms of performance!

So... Do I pass the Fizz Buzz test?


  1. I've heard about that. My friend said he had read something similar and you may find it from view more


Post a Comment

Popular posts from this blog

Functional Programming as a Case of Math Envy

Lies, damned lies, and mathematics. - Mark Twain

You know that something is fishy when people start using complex math when they don't need it.

Immutability, no side effects? Yes, when it makes sense. Every smart developer will get to this point eventually.

But category theory everywhere? I call it math envy.

Do you really think that because you are using only pure functions your program will be bug free? More performant? Faster to develop? Easier to maintain?

The Engineering Mindset Overreliance Error

In my previous startup life, I built a web application which purpose was to help companies screen applicants during the recruitment process, so that they could recruit employees that were the best fit for them. Our product was quite innovative in the sense that it matched the personality of applicants with the culture of the recruiting company. In order to do that, we would first send questionnaires to the current employees of the company to determine its culture, and then we used statistics, machine learning, artificial intelligence to compute a fitness score for applicants, based on their answers to their own questionnaire. The idea was well-received and we got a few clients pretty fast.

Problems began we started improving our solution. Reading the scientific literature on recruitment, it soon appeared that IQ was the single most important factor for predicting future performance of employees. As our goal was to help companies recruit the best people for them, it seemed logical for …