[Haskell-beginners] Improve my lambda expressions

Frerich Raabe raabe at froglogic.com
Wed Jun 28 06:26:20 UTC 2017


On 2017-06-27 18:35, PATRICK BROWNE wrote:
> Thanks for all your help.
> I was unaware that there was a relation between let/where and lambdas.
> Here is my effort to use a single lamda
> md3 n = (\n -> (dist  (Point (4.0 + 0.5 * n) (4.0 - 0.5 * n)) (Point (n * 
> 1.0) ( n * (-1.0))))) n
> 
> I imagine that this function could be written without lambdas, let, or 
> where.

Indeed, it could. Note that your definition has the form

   md3 n = (\n -> (dist )) n

I.e. the expression 'md3 n' is equivalent to the expression '(\n -> (dist 
..)) n', which means 'apply the lambda expression to n'. You don't need the 
lambda expression if you apply it to a given argument directly though, i.e. 
the above definition is equivalent to

   md3 n = dist ..

> Is it generally true the all/most functions could be written without 
> lambdas, let, or where?

I believe it is true since you could define any function as a global 
definition (i.e. not a nested scope as in let..in or where).

-- 
Frerich Raabe - raabe at froglogic.com
www.froglogic.com - Multi-Platform GUI Testing


More information about the Beginners mailing list