Syntactic Sugar II: let and where
Learn how to split complex expressions into reusable subexpressions.
We'll cover the following
Let’s continue discovering some of the syntactic sugar that Haskell offers us. In this lesson, we focus on bindings for subexpressions.
Sometimes when writing functions, the expressions on the right hand side of equations can become quite complex, especially when they involve repeated subexpressions. For example, consider the task to write a function which solves the quadratic equation
We know that this equation has solutions as long as
and these solutions are equal to
Let’s translate this into a Haskell function, ignoring for now the case where there are no solutions.
Get hands-on with 1400+ tech skills courses.