I am not sure if this is good programming practice, but I would like to know if one can define a recursive function using the lambda expression.
This is an artificial example I made up: So one can defined the factorial function in Haskell recursively as follows
factorial :: Integer -> Integer
factorial 1 = 1
factorial (n + 1) = (n + 1) * factorial n
Now, I want a function f such that f n = (factorial n) + 1. Rather than using a name for factorial n (i.e. defining it before hand), I want to define f where factorial n is given a lambda expression within the definition of f. Can I use a recursive lambda definition in f in place of using the name factorial?
letandwhere.n+kpatterns as used in your definition offactorialhave been removed from the language as of Haskell 2010. It's advisable to stop using them.factorial 0 = 1which will allow it to work for one more numberData.Function (fix)