Giving these definitions (let
is found in Haskell documentation):
fix :: (a -> a) -> a
fix f = let x = f x in x
fact = fix (\f -> \x -> if x <= 1 then x else x * f (x-1))
I'll try to explain how fix works.
Let's reduce fact
Giving these definitions (let
is found in Haskell documentation):
fix :: (a -> a) -> a
fix f = let x = f x in x
fact = fix (\f -> \x -> if x <= 1 then x else x * f (x-1))
I'll try to explain how fix works.
Let's reduce fact