Examples where compiler-optimized functional code performs better than imperative code
There are cases where the same algorithm will optimize better in a pure context. Specifically, stream fusion allows an algorithm that consists of a sequence of loops that may be of widely varying form: maps, filters, folds, unfolds, to be composed into a single loop. The equivalent optimization in a conventional imperative setting, with mutable … Read more