logo

Crowdly

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

✅ Перевірена відповідь на це питання доступна нижче. Наші рішення, перевірені спільнотою, допомагають краще зрозуміти матеріал.

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.

Більше питань подібних до цього

Хочете миттєвий доступ до всіх перевірених відповідей на www.icorsi.ch?

Отримайте необмежений доступ до відповідей на екзаменаційні питання - встановіть розширення Crowdly зараз!