logo

Crowdly

Associativity We'd like to write slightly bigger programs. We probably want t...

✅ The verified answer to this question is available below. Our community-reviewed solutions help you understand the material better.

Associativity

We'd like to write slightly bigger programs. We probably want to nest function calls. How can we do that, with Haskell's unusual syntax?

As a silly example, let's try to negate a boolean twice using the not function. Think about how you would do that.

You may have thought about doing it like this:

not not True

That doesn't work, though, because "function application" associates to the left. What does it mean? The expression we wrote above is equivalent to:

(not not) True

This cannot possibly work, because the first not expects an argument of Bool (and instead it received a function), and the second not doesn't have any argument.

Use the parentheses appropriately to write the call of not twice on True. Use the REPL to experiment.

More questions like this

Want instant access to all verified answers on www.icorsi.ch?

Get Unlimited Answers To Exam Questions - Install Crowdly Extension Now!