
I've used a similar function myself, but why write it in such a complicated way? How about lfp :: Eq a => (a -> a) -> a -> a lfp f x | f x == x = x | otherwise = lfp f (f x) Edsko On 19 Mar 2009, at 09:49, Jens Blanck wrote:
Hi,
I found myself writing the following
leastFixedPoint :: (Eq a) => (a -> a) -> a -> a leastFixedPoint f x = fst . head . dropWhile (uncurry (/=)) $ zip l (tail l) where l = iterate f x
and was a bit surprised that I couldn't get any matches on hoogle for the type above. The closest one is fix :: (a -> a) -> a but that sort of assumes that we're starting the fixed point search from the bottom element (undefined).
Anyway, is there a nicer way of doing the above?
Jens
_______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe