LISP LISt Processing. History & Overview b b One of the oldest high level programming languages. b b First developed in 1958 by John McCarthy. b b Later.

Slides:



Advertisements
Similar presentations
Lisp. Versions of LISP Lisp is an old language with many variants Lisp is alive and well today Most modern versions are based on Common Lisp LispWorks.
Advertisements

C-LISP. LISP 2 Lisp was invented by John McCarthy in 1958 while he was at the Massachusetts Institute of Technology (MIT).John McCarthyMassachusetts Institute.
1 Scheme and Functional Programming Aaron Bloomfield CS 415 Fall 2005.
Lists in Lisp and Scheme a. Lists are Lisp’s fundamental data structures, but there are others – Arrays, characters, strings, etc. – Common Lisp has moved.
Functional Programming. Pure Functional Programming Computation is largely performed by applying functions to values. The value of an expression depends.
1 Programming Languages and Paradigms Lisp Programming.
Lambda Calculus and Lisp PZ03J. Lambda Calculus The lambda calculus is a model for functional programming like Turing machines are models for imperative.
Chapter 3 Functional Programming. Outline Introduction to functional programming Scheme: an untyped functional programming language.
LISP Programming. LISP – simple and powerful mid-1950’s by John McCarthy at M.I.T. “ LIS t P rocessing language” Artificial Intelligence programs LISP.
Helper functions: when extra arguments are needed Consider this problem: we want a function index_items that takes a list L and gives a number to each.
Lisp – Introduction יעל נצר מערכות נבונות סמסטר ב' תשס"ו.
PZ10CX Programming Language design and Implementation -4th Edition Copyright©Prentice Hall, PZ10CX - LISP Programming Language Design and Implementation.
Introduction to Artificial Intelligence Lisp Ruth Bergman Fall 2002.
Lisp. Versions of LISP Lisp is an old language with many variants –LISP is an acronym for List Processing language Lisp is alive and well today Most modern.
LISP primitives on sequences FIRST (or CAR) and REST (or CDR) take lists apart. Consider the list (First day of the semester). * (first '(First day of.
Copyright © 2006 The McGraw-Hill Companies, Inc. Programming Languages 2nd edition Tucker and Noonan Chapter 14 Functional Programming It is better to.
TES3111 Oct 2001 Data Structures S-Expression - Symbolic expression. It can be an Atom, a List or a collection of S- Expression enclosed by (…) Atom -
Common Lisp Derek Debruin Mark Larue Vinh Doan. Problem Domains There was a need in the early 1960s to define a programming language whose computational.
Symbolic Expressions (S Expressions) Syntax: Opening and Closing parenthesis having elements in between. List represented in LISP: (A B2 C3 Shahid) (A.
TES3111 October 2001 Artificial Intelligence LISP.
Lisp by Namtap Tapchareon Lisp Background  Lisp was developed by John McCarthy in  Lisp is derives from List Processing Language. 
LISP 1.5 and beyond A very quick tour. Data Atoms (symbols) including numbers – All types of numbers including Roman! (well, in the early days) – Syntactically.
Lisp: a history Developed by John McCarthy in the 1950’s. Developed by John McCarthy in the 1950’s. Only Fortran has higher “seniority” Only Fortran has.
Genetic Programming.
Comp. Eng. SW Lab II: FP with Scheme 1 Computer Eng. Software Lab II , Semester 2, Who I am: Andrew Davison CoE, WiG Lab Office.
1 Lists in Lisp and Scheme. 2 Lists are Lisp’s fundamental data structures. Lists are Lisp’s fundamental data structures. However, it is not the only.
1 Lisp Functions –Built-in functions –Defining functions –Function Evaluation and Special Forms defun, if Control statements –Conditional if, cond –Repetition.
Functional Programming in Scheme
KU NLP Artificial Intelligence1 Ch 15. An Introduction to LISP q 15.0 Introduction q 15.1 LISP: A Brief Overview  Symbolic Expressions, the Syntactic.
Input, Output, and Processing
Copyright © 2012 Pearson Education, Inc. Publishing as Pearson Addison-Wesley C H A P T E R 2 Input, Processing, and Output.
Basic LISP Programming Common LISP follows the algorithm below when interacting with users: loop read in an expression from the console; evaluate the expression;
Lisp Functional Language or Applicative Language –Achieves its effect by applying functions, either recursively or through composition Powerful, expressive,
Programming in Lisp; Instructor: Alok Mehta Programming in Lisp Introduction to Lisp.
LISP Data Types Functional Programming Academic Year Alessandro Cimatti
UMBC CMSC Common Lisp II. UMBC CMSC Input and Output Print is the most primitive output function > (print (list 'foo 'bar)) (FOO BAR) The.
Scheme Profs Tim Sheard and Andrew Black CS 311 Computational Structures.
Milos Hauskrecht (PDF) Hieu D. Vu (PPT) LISP PROGARMMING LANGUAGE.
Introduction to LISP Atoms, Lists Math. LISP n LISt Processing n Function model –Program = function definition –Give arguments –Returns values n Mathematical.
FUNCTIONS. Midterm questions (1-10) review 1. Every line in a C program should end with a semicolon. 2. In C language lowercase letters are significant.
Ada, Scheme, R Emory Wingard. Ada History Department of Defense in search of high level language around Requirements drafted for the language.
C H A P T E R E I G H T Functional Programming Programming Languages – Principles and Paradigms by Allen Tucker, Robert Noonan.
EZGİ GENÇ History Lisp is a family of computer programming languages with a long history and a distinctive, fully parenthesized syntax. Originally.
Ch Ch jcmt CSE 3302 Programming Languages CSE3302 Programming Languages (n-n-n-notes) Summer 2003 Dr. Carter Tiernan.
1 Outline Review Introduction to LISP Symbols and Numbers Lists Writing LISP Functions LISPWorks.
Functional Programming Languages
Topics Designing a Program Input, Processing, and Output
Section 15.4, 15.6 plus other materials
A I (Artificial Intelligence)
Organization of Programming Languages
CS 326 Programming Languages, Concepts and Implementation
Lists in Lisp and Scheme
LISP LISt Processing.
LISP A brief overview.
PZ10CX - LISP Programming Language Design and Implementation (4th Edition) by T. Pratt and M. Zelkowitz Prentice Hall, 2001 Section Appendix A.6.
Mini Language Interpreter Programming Languages (CS 550)
Lisp Tutorial Click on Xlisp icon – you enter the interpreter
Lisp, Then and Now.
LISP A brief overview.
Topics Designing a Program Input, Processing, and Output
Defining Functions with DEFUN
LISP LISt Processing.
Abstraction and Repetition
Topics Designing a Program Input, Processing, and Output
LISP LISt Processing.
Modern Programming Languages Lecture 18 Fakhar Lodhi
Common Lisp II.
Lisp.
LISP primitives on sequences
Lists in Lisp and Scheme
Presentation transcript:

LISP LISt Processing

History & Overview b b One of the oldest high level programming languages. b b First developed in 1958 by John McCarthy. b b Later adopted as the primary research language of Artificial Intelligence (AI). b b The syntax of LISP is one of the least restrictive of any high- level programming languages.

History & Overview b b Was originally developed as an interpreted language, however, a number of current versions of LISP make use of an incremental compiler. b b Among LISP's strongest features is that programs may be treated as data. b b In LISP, entire programs can be used as input to other programs or sub-procedures directly.

Grammar List :: = ( [X 1 X 2 … X n ]) List :: = ( [X 1 X 2 … X n ]) X :: = List | Atom X :: = List | Atom Atom :: = Number | Name Atom :: = Number | Name Number :: =... | |... | -2 | 1 | 0 | 1 | 2 |... | 1024 |... Number :: =... | |... | -2 | 1 | 0 | 1 | 2 |... | 1024 |... Name :: = a sequence of alphanumeric characters containing at least one letter and no separators Name :: = a sequence of alphanumeric characters containing at least one letter and no separators Separator :: =. | space | ( | ) | [ | ] | ‘ | tab | carriage return all are characters with a particular role. Separator :: =. | space | ( | ) | [ | ] | ‘ | tab | carriage return all are characters with a particular role.

Features/Parts of LISP Definitions b Atom : A series of numbers or symbols that can’t be broken in to smaller components. Ex. Cat, Scott9, 684, 7Hearts, This-Is-A-Very-Long-Atom b List : A sequence of atoms or other lists enclosed by parentheses LISTLENGTH b () 0 (John gives Mary a book) 5 ((subject) (verb) (object)) 3 ((+ X Y) (+ A B)) 2 (1 2 3 A B C C B A 3 2 1) 12 (()()) 2

Features/Parts of LISP Syntax b The basic syntax for LISP is : (expression) b Everything is expressed as a list or as part of a list, enclosed in parentheses b Not case-sensitive b Supports recursion

Features/Parts of LISP Syntax b The comment character is a semi-colon ‘;’ which can appear anywhere. This results in the remainder of the line being skipped. b There are 2 main components of a list, the head of the list and the rest of the list. The head of the list or the first list item is referred to as CAR. The rest of the list is referred to as CDR. (Note: CAR & CDR were register names from the IBM mainframe that LISP was first written for.)

Features/Parts of LISP Syntax b Many times the CAR is a function with its arguments being CDR. The basic mathematical operations are a good example. (+ 4 2) (- 4 2) (* 4 2) (/ 4 2) b Note the syntax for all functions is simply a list of symbols and numbers. b All list operations return a value. This value is the last value in the list. For a procedure, the last value is the return or result value.

List Manipulation Some of the LISP primitives (built-in commands or functions) for manipulating lists are: b LIST - Returns a list of its arguments > (list ) SETQ - Takes at least 2 arguments, the 1st being a variable name and the 2nd being any LISP expression. LISP evaluates the expression passed as the 2nd argument and assigns the value returned as the new value of the variable passed as the 1st argument. > (setq mylist (list )) > (setq yourlist (list )) b SETQ - Takes at least 2 arguments, the 1st being a variable name and the 2nd being any LISP expression. LISP evaluates the expression passed as the 2nd argument and assigns the value returned as the new value of the variable passed as the 1st argument. > (setq mylist (list )) > (setq yourlist (list )) ( ) ( ) ( ) ( )

List Manipulation b CAR - Returns the first element of a list > (car mylist) 1 b CDR - Returns a list of all elements except the first > (cdr mylist) (2 3 4) (2 3 4) b Nth - Returns a specific list element > (nth 3 mylist) > (nth 2 yourlist)

List Manipulation b CONS - Short for concatenates. Will insert a new element at the front of a list > (cons (car mylist) (cdr mylist)) > (cons (car mylist) (cdr yourlist)) ( ) ( ) > (cons mylist yourlist) (( ) )

List Manipulation b APPEND - Adds new list elements to the end of a list > (append mylist yourlist) ( )

Functions b DEFUN - This command is used to define functions which LISP refers to as a value-returning procedures. > ( defun MyValueReturningProcedureName (optional_input_variables) ValueReturningProcedure_body )

Input/Output b PRINT & PRINC - These will output an expression to the output device followed by a space. PRINT adds a line-feed. b READ - This will read an expression from the input device.