From Imperative to Functional Programming: The Dijkstra Algorithm

From Imperative to Functional Programming: The Dijkstra Algorithm

A recursive function offers different branches, the most important one being the stop branch. The other branch contains the same code as before, with one small change: we compute the next node by calling the same function with the updated node. The function to be marked with The last instruction of the function should be the recursive call

Because our function conforms to the second condition, it’s a no-brainer to just add the keyword to it and optimize the generated bytecode.

Source: blog.frankel.ch