treat :: [a] -> ([a] -> b) -> [b]treat xs f = treat' [] xs where treat' :: [a] -> [a] -> [b] treat' xs [] = [] treat' xs (y:ys) = f (xs ++ ys) : treat' (xs ++ [y]) ys