Miranda (programming Language) - Sample Code

Sample Code

The following Miranda script determines the set of all subsets of a set of numbers

subsets = ] subsets (x:xs) = ++ y | y <- ys] ++ ys where ys = subsets xs

and this is a literate script for a function primes which gives the list of all prime numbers

> || The infinite list of all prime numbers, by the sieve of Eratosthenes. The list of potential prime numbers starts as all integers from 2 onwards; as each prime is returned, all the following numbers that can exactly be divided by it are filtered out of the list of candidates. > primes = sieve > sieve (p:x) = p : sieve

Read more about this topic:  Miranda (programming Language)

Famous quotes containing the words sample and/or code:

    All that a city will ever allow you is an angle on it—an oblique, indirect sample of what it contains, or what passes through it; a point of view.
    Peter Conrad (b. 1948)

    ... the self respect of individuals ought to make them demand of their leaders conformity with an agreed-upon code of ethics and moral conduct.
    Mary Barnett Gilson (1877–?)