Miranda Programming Language



Functional programming is based on the simplest of models, namely that of finding the value of an expression. This we meet in our first years at school, when we learn to work out expressions like 8+(3-2) by evaluating the two halves, 8 and (3-2), and adding the results together. Functional programming consists of our defining for ourselves functions like + which we can then use to form expressions. We define these functions by means of equations, like addD a b = 2*(a+b) (1) which we use to calculate the value of an expression like addD 2 (addD 3 4). We evaluate this using (1) to replace occurrences of addD with their values, so that we can write down a calculation of its value addD 2 (addD 3 4) = 2*(2 + (addD 3 4)) = 2*(2 + 2*(3 + 4)) = 32 Miranda is a trademark of Research Software Limited.