10.07.2015 Views

LISP I Programmer's Manual - Software Preservation Group

LISP I Programmer's Manual - Software Preservation Group

LISP I Programmer's Manual - Software Preservation Group

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

expression was, defined, the meaningless expression O* (0-1)!does not arise. The evaluation of 2! according to this definitionproceeds as follows:We now give two other applications of recursive functiondefinitions. The greatest common divisor, e(m,n), of twopositive integers m and n is computed by means of theEuclidean algorithm. This algorithm is expressed by the recursivefunction definition:where - rem(n,m) denotes the remainder left when n is divided by m.The Newtonian algorithm for obtaining an approximate squareroot of a number a, starting with an initial approximation - xand requiring that an acceptable approximation - y satisfy21 y -a I4 6, may be written as- sqrt (a,x,~) = ( Ix2-aIc E1 ax,T + sqrt (a,2(x+f) ,h).)The simultaneous recursive definition of several' functionsis also possible, and we shall use such definitions if theyare required.There is no guarantee that the computation determined by arecursive definition will ever terminate and, for example, anattempt to compute n! from our definition will only succeed ifn is a non-negative integer. If the computation does not terminate,the function must be regarded as undefined for thegiven arguments.

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!