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:

    The present war having so long cut off all communication with Great-Britain, we are not able to make a fair estimate of the state of science in that country. The spirit in which she wages war is the only sample before our eyes, and that does not seem the legitimate offspring either of science or of civilization.
    Thomas Jefferson (1743–1826)

    Faultless honesty is a sine qua non of business life. Not alone the honesty according to the moral code and the Bible. When I speak of honesty I refer to the small, hidden, evasive meannesses of our natures. I speak of the honesty of ourselves to ourselves.
    Alice Foote MacDougall (1867–1945)