Find an ideal speed to cross all traffic lights when they are green
I wanted to use List.tail for the recursion, but I couldn't find how to get the whole list back when I needed to restart the recursion.


Easy! You can pass the whole list as an additional parameter.

My Scala is a bit rusty, but I think you can write like this using pattern matching:

def computeIdealSpeed(currentSpeed: Float, lights: List[TrafficLight], allLights: List[TrafficLight]): Float = {
    lights match {
        case light::tail =&gt; {
            val newSpeed = light.getIdealSpeed(currentSpeed)
            if (newSpeed != currentSpeed) {
                computeIdealSpeed(newSpeed, allLights, allLights)
            } else {
                computeIdealSpeed(newSpeed, tail, allLights)
            }
        }
        case nil =&gt; currentSpeed
    }
}


And then call the method with:

val idealSpeed = computeIdealSpeed(speed, lights, lights)


I'm not sure this is any better though. I would nitpick on the placement of braces and spacing around conditional statements, and the lack of indentation of the body of App.