Miranda does not have while- or for-loops (which in any case does not make sense without a volatile state). In most cases, you can use higher order functions. In cases where there is no higher order function that does what you need, you can use recursion.
For example, if you have the following while-loop in an imperative language:
f(start) { x = start while( !finished(x) ) { x = next(x) } return x }
You could express it recursively in Miranda as follows:
fx = if finished x then x else f (next x)
source share