leastfixedpoint

Tony's Link Log

All tags.

Paragraph flowing as a fold.

Wolfgang Corcoran-Mathe (2024)
🔗 https://www.sigwinch.xyz/cs/2024/flow-fold.html
#functional-programming #bcs2220 #bcs

An elegant example of FP for the FP portion of my PL course:

A simple, useful, plain-text variant of Donald Knuth’s paragraph-filling algorithm can be expressed as a fold. This algorithm runs in time linear to the length of its input and usually produces better results than the classic greedy text-flow algorithm.