Welcome to Scribd, the world's digital library. Read, publish, and share books and documents. See more
Standard view
Full view
of .
Look up keyword
Like this
0 of .
Results for:
No results containing your search query
P. 1
A Short Introduction to Lisp

A Short Introduction to Lisp

Ratings: (0)|Views: 8|Likes:
Published by fran_gomez_18

More info:

Published by: fran_gomez_18 on Dec 12, 2012
Copyright:Attribution Non-commercial


Read on Scribd mobile: iPhone, iPad and Android.
download as DOC, PDF, TXT or read online from Scribd
See more
See less





A Short Introduction to Lisp
PWGL is based on Lisp. Learning Lisp is highly recommended and beneficial as itallows:(1) to better understand the visual Patch, (2) to use PWGLConstraints and ENP-Script, (3) to understand the various Lisp-based representations (such asENP-score-notation), (4) to create functions, and (5) to create user-libraries.Lisp is a family of computer programming languages with a long history and adistinctive fully-parenthesized syntax. Originally specified in 1958, Lisp is thesecond-oldest high-level programming language in widespread use today; onlyFortran is older. Like Fortran, Lisp has changed a great deal since its earlydays, and a number of dialects have existed over its history. Today, the mostwidely-known general-purpose Lisp dialects are Common Lisp and Scheme.(Wikipedia)For further information about Lisp see:http://en.wikipedia.org/wiki/Lisp_%28programming_language%29Here are some recommended and free Online books about Lisp:http://www.cs.cmu.edu/~dst/LispBook/index.htmlhttp://www.gigamonkeys.com/book/http://www.cs.cmu.edu/afs/cs.cmu.edu/project/ai-repository/ai/html/cltl/clm/node1.htmlIf you are interested in learning Lisp outside PWGL environment a good alternativeis LispWorks Commond Lisp. PWGL itself is programmed with LispWorks and a freePersonal Edition can be downloaded from the companys web site:http://www.lispworks.com/downloads/index.html1
The syntax of Lisp is simple. Lisp expressions are written inside parentheses andthe elements are separated by spaces.
Functions and Data
The function operates on the data and returns a result. In a list the firstelement specifies the function. The remaining elements are the arguments, e.g: ________________________________________________________________ > (+ 1 2 3)6> (1- (* (/ 5 6) pi))1.6179938779914945D0> (defun sub-one(x) (- x 1))SUB-ONE ________________________________________________________________ 
The term data means information, such as numbers, words, or lists of things. Tomake a list data you need to use a special form called Quote. Quote returns itsargument without evaluating it.Without the quote, Lisp interpretes expressions as function calls (as describedabove). The special form quote tells Lisp not to evaluate the form but to treat itas a literal (i.e., data). There is a shorthand for quote function that is used byLisp programmers almost without exceptions and that is an apostrophe ('), e.g.,'(a b c d e) is the same as (quote (a b c d e)). The following demonstrates thedifference between quoted and not quoted expressions: _____________________________________________________________ > '(a b c d e)(a b c d e)> (a b c d e)Error: Undefined operator A in form (A B C D E).1 (continue) Try invoking A again.2 Return some values from the form (A B C D E).3 Try invoking SYSTEM::A with the same arguments.4 Set the symbol-function of A to the symbol-function of SYSTEM::A.5 Try invoking something other than A with the same arguments.6 Set the symbol-function of A to another function.7 Set the macro-function of A to another function.2
8 (abort) Return to level 0.9 Return to top loop level 0.Type :b for backtrace, :c <option number> to proceed, or :? for other options _______________________________________________________________ 
A symbol is a sequence of letters, digits, and permissible special characters(e.g., _,-,*,?,!). Numbers are not symbols. The characters colon (:), semi-colon(;) and comma (,) are to be avoided because they have special meaning in Lisp.Symbols are names that are used to bind to a value.Symbols can be used, for example, to:(1) store values,(2) recall values, (3) bind temporaral values, and (4) use as arguments to functions.Here is a list of some valid symbols:(1) midis (2) note1 (3) 24overtones (4) all-card-3-pcs (5) *current-harmony*.There are two special symbols, T and NIL. Lisp uses T and NIL to represent trueand false. Symbols like T and NIL are called 'self-evaluating symbols', becausethey evaluate to themselves.Symbols that starts with a colon are keywords: __________________________________________ > :notes:NOTES> :pitches:PITCHES __________________________________________ 3

You're Reading a Free Preview

/*********** DO NOT ALTER ANYTHING BELOW THIS LINE ! ************/ var s_code=s.t();if(s_code)document.write(s_code)//-->