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:

    As a rule they will refuse even to sample a foreign dish, they regard such things as garlic and olive oil with disgust, life is unliveable to them unless they have tea and puddings.
    George Orwell (1903–1950)

    Wise Draco comes, deep in the midnight roll
    Of black artillery; he comes, though late;
    In code corroborating Calvin’s creed
    And cynic tyrannies of honest kings;
    He comes, nor parlies; and the Town, redeemed,
    Gives thanks devout; nor, being thankful, heeds
    The grimy slur on the Republic’s faith implied,
    Which holds that Man is naturally good,
    And—more—is Nature’s Roman, never to be
    scourged.
    Herman Melville (1819–1891)