“Any function on finite lists that is defined by pairing the desired result with the argument list can always be redefined in terms of fold”
问题 I was reading through the paper A tutorial on the universality and expressiveness of fold, and am stuck on the section about generating tuples. After showing of how the normal definition of dropWhile cannot be defined in terms of fold, an example defining dropWhile using tuples was proved: dropWhile :: (a -> Bool) -> [a] -> [a] dropWhile p = fst . (dropWhilePair p) dropWhilePair :: (a -> Bool) -> [a] -> ([a], [a]) dropWhilePair p = foldr f v where f x (ys,xs) = (if p x then ys else x : xs, x