Higher-order functions translated from Haskell's Data.List module.