Gambit (v1.7)

: (define (fact x)
    (cond ((= x 0) 1)
          ((= x 1) 1)
          ((> x 1) (* (fact (- x 1)) x))
          (else    (error "argument must be positive"))))
fact

: (trace fact)
fact

: (fact 10)
Entry (fact 10)
|Entry (fact 9)
| Entry (fact 8)
|  Entry (fact 7)
|  |Entry (fact 6)
|  | Entry (fact 5)
|  |  Entry (fact 4)
|  |  |Entry (fact 3)
|  |  | Entry (fact 2)
|  |  |  Entry (fact 1)
|  |  |  ==> 1
|  |  | ==> 2
|  |  |==> 6
|  |  ==> 24
|  | ==> 120
|  |==> 720
|  ==> 5040
| ==> 40320
|==> 362880
==> 3628800
3628800

: (untrace fact)
fact

: (let ((x (runtime))) (let ((y (fact 50))) (cons (- (runtime) x) y)))
(.02 . 30414093201713378043612608166064768844377641568960512000000000000)

: (pp fact)
(lambda (x)
  (cond ((= x 0) 1)
        ((= x 1) 1)
        ((> x 1) (* (fact (- x 1)) x))
        (else (error "argument must be positive"))))
#f

: (define f fact)
f

: (define fact "not the factorial function")
fact

: (f 5)
*** ERROR IN f -- Operator is not a PROCEDURE
(fact (- x 1))

1: ,b
0    f                         (fact (- x 1))
-1   (top level)               (f 5)
-2   ##read-eval-print
-3   ##dynamic-env-bind
-4   ###_kernel.startup

1: ,p
#[procedure f] =
(lambda (x)
  (cond ((= x 0) 1)
        ((= x 1) 1)
        ((> x 1) (* (fact (- x 1)) x))
        (else (error "argument must be positive"))))

1: ,l
x = 5

1: (- x 1)
4

1: fact
"not the factorial function"

1: (set! fact f)
#[undefined]

1: ,r (fact (- x 1))
120

: (list (gensym) (gensym) (gensym))
(g1 g2 g3)

: (put 'bob 'eyes 'blue)
#f

: (put 'mary 'hair 'blond)
#f

: (get 'bob 'eyes)
blue

: (get 'mary 'eyes)
#f

: (define (series term)
    (let ((sum 0) (stop #f))
      (FUTURE (let loop ((i 0))
                (if (not stop)
                  (begin (set! sum (+ sum (term i))) (loop (+ i 1))))))
      (lambda (msg)
        (cond ((eq? msg 'value) sum)
              ((eq? msg 'stop)  (set! stop #t))
              (else             (error "unknown message" msg))))))
series

: (define pi (series (lambda (i) (/ 4. ((if (odd? i) - +) (+ (* i 2) 1))))))
pi

: (pi 'value)
3.141419882340216

: (pi 'value)
3.1415194471477133

: (pi 'value)
3.1416300745380195

: (pi 'value)
3.1415798589941843

: (pi 'stop)
#[undefined]

: (pi 'value)
3.1415815090449892

: (pi 'value)
3.1415815090449892

: ,q
