[Haskell-beginners] Lambda expression currying

Francesco Ariis fa-ml at ariis.it
Tue Dec 22 06:54:46 UTC 2020


Hello Lawrence,

Il 21 dicembre 2020 alle 23:59 Lawrence Bottorff ha scritto:
> addThree :: (Num a) => a -> a -> a -> a
> addThree = \x -> \y -> \z -> x + y + z
> […]
>
> But how is the beta reduction happening with addThree?

Should be:

addThree = (\x -> \y -> \z -> x + y + z) 1 2 3
         = (\y -> \z -> 1 + y + z) 2 3              beta
         = (\z -> 1 + 2 + z) 3                      beta
         = 1 + 2 + 3                                beta
         = …

Does that make sense?
—F


More information about the Beginners mailing list