Suppose we have the following definition of a function powerb(x,n) that computes xn :

(defun powerb (x n)
  (if (= n 0)
      (if (evenp n)
          (square (powerb x (/ n 2)))
          (* x (powerb x (- n 1))))))

If this is used with a constant argument n, as is often the case, the function can be partially evaluated into more efficient code:

(gldefun t3 ((x real)) (powerb x 5))

(glcp 't3)
result type: REAL
The recursive function calls and interpretation ( if statements) have been completely removed; only computation remains. Note that the constant argument 5 is gone and has been converted into control.

Contents    Page-10    Prev    Next    Page+10    Index