I am trying to understand what's useful and how to actually use lambda expression in Haskell. I don't really understand the advantage of using lambda expression over the convention way of defining functions. For example, I usually do the following:
let add x y = x+y
and I can simply call
add 5 6
and get the result of 11 I know I can also do the following:
let add = \x->(\y-> x+y)
and get the same result. But like I mentioned before, I don't understand the purpose of using lambda expression. Also, I typed the following code (a nameless function?) into the prelude and it gave me an error message.
let \x -> (\y->x+y)
parse error (possibly incorrect indentation or mismatched backets)
Thank you in advance!
let \x -> (\y->x+y)statement - theletstatement is used to give names to things. In its simplest form, the statement looks likelet name = expression. And from that point you usenameeach time you want to refer toexpression. In your example,\x -> (\y->x+y)is an expression (a value of function type). So, your whole statement has the formlet expression, no names bound. It has no point such way. Let expression what?