Search code examples
functional-programmingmiranda

Miranda Language - Function lambda


I have been studying the functional paradigm for some time and in this period I made some successes and several mistakes and it was with those mistakes where I really learned the most. I believe that a good way to learn a computational paradigm is to take some languages from that paradigm and massively test the same algorithms. It is when it is realized that not everything that is accepted in one language is shared in another. This makes it possible to find a construction path that is common to the set of languages and consequently has in this essence a more pure and assertive logical abstract reasoning. My journey is related to the preparation of classes on functional logic.

In this study I am trying to develop (as a learning process) functions that detect the head, the tail, the last element of a list, among others that are often found ready-made in languages.

I started with an experimental language called Hope, I moved to Haskell, and then I went to OCaml, ML (SML / NJ) and F #. Now I am doing the same tests in the Miranda language.

After this introduction, I found little information about the Miranda language and in the set of material, I had access to, I did not find certain information that I would like to know if someone has this knowledge and can share it:

How to make use of anonymous function (lambda) in Miranda, if it exists?

Thank you in advance.


Solution

  • There is no lambda in Miranda. But if not using continuations, it is no problem. As a workaround, I always use:

    result = foldl lambda 0 [1..10]
             where lambda x y = x+y
    

    instead of Haskell's:

    result = foldl (\x y -> x+y) 0 [1..10]
    

    Cheers, Dusterbraut