CodePlexProject Hosting for Open Source Software

If you haven't ever seen scheme programs, the syntax can look odd at the first glance. There are parenthesis all over the place, and the name of the function (or operator) always comes first.

Functions are defined using*define* keyword:

and this function can be later used as:

Now let's see how a simple recursion can be added - we wil calculate factorial function (same as we've already seen in example with static calculation):

> (+ 2 4) 6

Functions are defined using

(define (sum a b) (+ a b))

and this function can be later used as:

> (sum 2 4) 6

Now let's see how a simple recursion can be added - we wil calculate factorial function (same as we've already seen in example with static calculation):

(define (fact n) (if (= n 0) 1 (* n (fact (- n 1))))) > (fact 10) 3628800

Last edited Nov 30, 2007 at 4:04 AM by migo, version 2