22
May

LISP PROGRAMMING



hello my name is Nass in this presentation I'm going to present you the list family of languages Lisp is a family of computer programming languages with a long history and a distinctive fully parenthesized polish previous notation originally specified in 1958 by John McCarthy this pieces second oldest high-level programming language in widespread use today only four strands altered by one year lease has changed a great deal since its early days the number of dialects had existed over its history today the most widely known general-purpose list at least dialects are Common Lisp and scheme Lisp Oswald was originally created as a practical mathematics a notation for computer programs influenced by the notation of Harlem's or Church lambda calculus it quickly became the favorite programming language for artificial intelligence research some of the things least invented are conditioners a conditional is an if-then-else constant we take this for granted now they were invented by McCarthy in the course of developing Lisp for that the time only had a condition called too closely based on the branch instruction in the underlying hardware McCarthy who was on the Arkell committee got conditional into alcohol when they spread to most other languages a function type in Lisp functions are first class objects they are a data type just like integer strings etc and have a little representation can be stored in variables can be passed as arguments and so on rakesh a location existed as mathematical concept before release of course at least was the first programming language to support circular implicitly making functions first grab objects invented garbage collection as well now we're going to talk about dialects of Lisp over its 50-year history liscus has found many variations moreover each given dialect may have several implementations for instance there are modern dozen implementations of common lisp differences between dialects may be quite visible for instance common lisp uses a key word different to name a function but scheme uses defined within a dialect that is standardized however performing implementations are for the same core language but with different extensions and libraries major dialects the two major dialects of lisp used for general-purpose programming today are Common Lisp and scheme these languages represent significantly different design choices commonly species access automat lisp it has many of the features of this machine lisp a large in lisbon dialect used to program these machines but was designed to be efficiently implementable on any personal computer or workstation Common Lisp has a large language standard including many built-in data types functions macros and other language elements as well as an object system commonly sports on borrowed certain features from scheme such as lexical scoping and lexical closures scheme designed earlier is a more minimalist design with a much smaller set of standard features but with certain implementation features such as tail call optimization and full continuations not necessarily found in common lisp schemas study statically scoped and properly tailored cursive dialect of the lisp programming language it was designed to have exceptionally clear and simple semantics and few different ways to form work expressions a wide variety of programming paradigms including imperative functional and message-passing styles find convenient expression scheme scheme continues to evolve with a series of standards in the series of scheme requests for implementation closure is a recent dialect of lisp principally targets and java virtual machine as well as the common language runtime the Python virtual machine there MP virtual machine and compiling to JavaScript lag Matic general-purpose language closure draws considerable influences from Haskell and places a very strong emphasis on immutability closure is a compiled language as it combines directly to java virtual machine bytecode yet remains completely dynamic now we're going to write a few sample programs in skim so first we have to install the scheme interpreter you can do this by using the following command then you present there but I am happy I have installed it so I'm not going to again as you see gambizzi's on delay donor I didn't give you special so I'm going to close the terminal now and create a new document a text file scheme source files must have the extension SCM let's name this okay so to display text using scheme we must type display followed by the string we want to show he'd saved to run the program we type GSI and the filename as you see the output is what we expected a lot more for our next program who are going to write we're going to see how expressions are formed so we create a file named explorations SCM open it with your favorite editor explorations in scheme must be in polish notation so if we want to calculate 5 plus 3 we must write plus circle size 3 we're using new line command to show in u9 now I went I'm going to calculate 5 plus 3 multiplied by 6 so Hey +5 3 that this must be multiplied by 6 so that's the way we have to do it I saved the file and now using GSI I'm going to execute they ever going to during the night okay the results are correct now we're going to see how to declare functions so I created a scheme file and named functions to define a function we must type we must read by typing define the functions name would say we're going to declare a function that returns the subtraction of two in two variables so we're gonna be sub two now to call it display sound – six and you like to live we expect that there is the output to before that is correct now to do some more useful things a program must contain if statements so we're going to create a functions that does something or doesn't do something depending on the condition so we're going to write a function that returns the absolute value of so as before we declare a function by using define we open the parentheses the function name the argument close the parentheses and we type if where you will have to use polish notation so that's the way to travel if a is larger than zero return a else a x minus one to make it positive so if the if statement is true then this is executed or this is not so we're going to call it we're going to to print the absolute value of 10 zero and minus three just to be sure that everything works the way it should so the output is correct finally we're going to see how recursion works we're going to declare a function that returns the factorial of a number so we're going to define function factorial that takes a single argument if the argument is equal to zero we must return one because factorial of zero is one else we must return an x factorial of n minus one we could save and we quit display four which is 24 we were relieved a new line we save and we execute it seems I named them if I gave you the hilar on the name anyway as we see it's correct a neat feature of skin is that it has built-in support for four big numbers this means that I can type factorials seventy thousand eight hundred ninety-nine which is a number that doesn't feed on 32 bits or even 64 bits but as we see skin say what to calculate it that's the end of the presentation I hope you enjoyed