foldr' and foldl' extended.