If the candidate tour is worse than the existing tour, still maybe accept it, according to some probability.
The probability of accepting an inferior tour is a function of how much longer the candidate is compared to the current tour, and the temperature of the annealing process.
A higher temperature makes you more likely to accept an inferior tour
Why would you need a simulated annealing for a seemingly so simple function?
I think they would really fit the language well. The good part is:
* Only the package and import statement change, the rest of your code stay the same and is not cluttered
* They are easier to reason about as it is more coarse grained
* They do not break the compatibility
The the bad part is:
* You cannot implement filter/map/reduce (but being able to implement them would conflict with the orthogonality of the language)
* It could lead to code bloat, but not more than manually copy pasting the code.