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.

3. <strong>LISP</strong> PrimerThe features of <strong>LISP</strong> described in this section permit theuser to define a number of S-functions and then compute the resultsof applying them to arguments.3.1 Definition of FunctionsIn,order to define functions we punch the following (usingcolumns 1-72 of as many cards as are necessary):DEFINE (((name of first function, definition of first function),(name of, second function, definition of second function),. .(name of last function, definition of last function)1 1 (1For example, if we wish to define the functions - ff, -9 altand subst given byff [XI = [atom[x] + x;T -+ ff [car[x] 1 ]alt[x] = [null[x]~null[cdr[x]] + x;T4 cons[car[x];alt[cdr[cdr[xlllllsubst[x;y;z] = [atom[z] + [eq[y;z] + x;T + z];~ -) cons[subst[x;y;car[z]];subst[x;y;cdr[z]]]]we writeDEFINE ( ((FF (LAMBDA (x) (COND ((ATOM X) X) (T (FF (CAR x))))))(ALT LAMBDA (x) (COND ((OR (NULL X) (NULL (CDR X)) ) X)(T (CONS (CAR X) (ALT (CDR (CDR X) ) ) ) ) ) ) )

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

Saved successfully!

Ooh no, something went wrong!