## Sorting Algorithms in Scheme

I will talk about three distinct sorting algorithms. Perhaps, the easiest to implement is the quicksort. In short, it sorts the input by positioning the input around the first element(pivot) and recursively sorts thepartitions. Here is the implementation:

The second algorithm is insertion sort. It sorts the list through successive insertions tocorrect places.

## Pattern Matching in Scheme

Here is a procedure that counts patterns in a sequence of words:

If we define an example as (define *test* ‘(a b c a b a b a b c b c b c a b c)) Then we get (match ‘(a b c) *test*) => 3 (match ‘(a b c) ‘()) => 0 […]

## Finding Fixed Points in Scheme

A number x is called a fixed point of a function if x satisfies the equation f(x)=x. We can locate a fixed point by beginning with an initial guess and applying f repeatedly, f(x), f(f(x)), f(f(f(x))),… Note that we need a tolerance to find two succesive values whose difference is less than it.

Then […]

## Half-Interval Method in Scheme

Half-interval method is used to find roots of an equation given that points a and b are f(a)<0<f(b). Thus, we assume that we are initially given the funtion together with points at which its values are negative and positive. Here is the algorithm:

This following example uses half-interval method to approximate pi as the […]

## Derivative Calculator in Scheme

In order to develop a derivative calculator in Scheme we need to learn about symbols. First we need to learn quote keyword. (define x 3) x (quote x) gives us 3 x See that quote procedure returns the actual symbol used not the value of the symbol x. What quote does is to create a […]

## Lists and HOPs in Scheme

HOPs stands for higher order procedures. They are actual procedures which input or oupt other procedures or both. We will come ack to HOPs later. Lists in Scheme are created by the keyword list. (list 1 2 3) creates a list ‘(1 2 3). The ‘ actually identifies this expression as list and states that it […]

## Tower of Hanoi in Scheme

Tower of Hanoi is a famous puzzle. If you do not know anything about it please check this site to have an idea. http://www.mazeworks.com/hanoi/index.htm  In this puzzle the aim is to take the blocks from one stick and put them in another one in the same order. Smaller blocks cannot go over the bigger ones […]

## Some Scheme Tools

order to develop your own Scheme programs you need some tools. Actually, there are two considerable options which are MIT Scheme and PLT Scheme. Both have some debugging options, but it is easier to use PLT Scheme since it has a more developed GUI interface. It is up to you which one to choose. http://download.plt-scheme.org/drscheme/ (PLT […]

## Change Counter Algorithm in Scheme

In this post we will examine an algorithm example. The question is: In how many different ways can we add up to 1 dollar by using 1,5 10, 25, 50 cents? First, we need to simplify or clarify the question. The ways that we can get to an amount of money with n different changes […]