Alex Rivera | Logout

What fun can be had with lambda-definitions?

Asked 2010-02-18T22:12:38.143
10

Not having them used them all that much, I'm not quite sure about all the ways lambda-definitions can be used (other than map/collect/do/lightweight local function syntax). For anyone interested in posting some examples:

  • provide explanations to help readers understand how lambda-definitions are being used;

  • preferred languages for the examples: Python, Smalltalk, Haskell.

Edit
Report

1 Answer

0

An example in Haskell to compute the derivative of a single variabled function using a numerical approximation:

deriv f = \x -> (f (x + d) - f x) / d
  where
    d = 0.00001

f x = x ^ 2
f' = deriv f -- roughly equal to f' x = 2 * x
answered 2010-02-24T04:56:29.477

Your Answer