Home > front end >  Explanation of lambda functions in Haskell
Explanation of lambda functions in Haskell

Time:10-26

what is the x doing at the end? Why do I need to write it there?

(\x -> (>=5) x)

If I am calling the function like this: (\x -> (>=5) x) 5, what is the second x doing? Maybe someone can explain this to me.

CodePudding user response:

The (>= 5) is a section of an infix operator [Haskell-wiki], it is equivalent to \y -> y >= 5, it is thus a function, and we apply x to that function. This thus means that:

\x -> (>= 5) x

is thus equivalent to:

\x -> x >= 5

or simply:

(>= 5)

due to η-reduction [Haskell-wiki].

  • Related