How exactly do I convert this let/where function to a lambda in Haskell?
Let statement form:
calc x = let ad5 x = x + 5
sqr x = x * x
dbl x = x * 2
in
ad5 . sqr . dbl $ x
Where declaration form:
calc x = ad5 . sqr . dbl $ x
where
ad5 x = x + 5
sqr x = x * x
dbl x = x * 2
Lambda form? Maybe similar to this example from Get Prog, where the variables are declared first, and then defined at the bottom:
sumSqrOrSqrSum4 x y = (\sumSqr sqrSum ->
if sumSqr > sqrSum
then sumSqr
else sqrSum) (x^2 + y^2) ((x + y)^2)
(\x -> ((x+5)*(x+5))*2) 4would result in 162. It's not elegant but is short and may work.