Miranda Language - Function lambda

208 Views Asked by At

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.

2

There are 2 best solutions below

1
On BEST ANSWER

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

0
On

After further research, I ended up giving up the information, since I was not finding anything. That is when I came across the document “Haskell for Miranda Programmers” by Kevin Glynn and Bernard Pope, published in 1999 that informs on page 8 (http://www.berniepope.id.au/assets/files/mira2hask.pdf) that Miranda only operates with named functions.

In Miranda, all functions have to be named. In Haskell, a function object can be written using lambda notation. The function definition consists of “" followed by a list of parameters, a “->" and a body expression (…).