CSE 341 -- S. Tanimoto Introduction 1 LISP Lisp is worth learning for the profound enlightenment experience you will have when you finally get it; that.

Slides:



Advertisements
Similar presentations
Introduction to LISP Programming of Pathway Tools Queries and Updates.
Advertisements

CS 63 LISP Philip Greenspun's Tenth* Rule of Programming:
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 Copyright © 1998 by Addison Wesley Longman, Inc. Chapter 14 Functional Programming Languages - The design of the imperative languages is based directly.
1 Scheme and Functional Programming Aaron Bloomfield CS 415 Fall 2005.
Scheme in Scheme. Why implement Scheme in Scheme  Implementing a language is a good way to learn more about programming languages  Interpreters are.
1 Programming Languages and Paradigms Lisp Programming.
Peter Seibel Practical Common Lisp Peter Seibel
Lisp – Introduction יעל נצר מערכות נבונות סמסטר ב' תשס"ו.
1 Functional programming Languages And a brief introduction to Lisp and Scheme.
Introduction to Artificial Intelligence Lisp Ruth Bergman Fall 2002.
Introduction CSC 358/458 3/27/2006. Outline Introductions Course goals Course organization History of Lisp Lisp syntax Examples Lisp IDE.
CSE S. Tanimoto Macros 1 Defining Macros in Lisp Extensibility: A language is extensible if the language can be extended. New Lisp control structures.
CMSC 471 LISP. Why Lisp? Because it’s the most widely used AI programming language Because it’s good for writing production software (Graham article)
CSE S. Tanimoto Explicit Function Application 1 Explicit Application of Functions, Functional Arguments and Explicit Evaluation Implicit and explicit.
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.
TES3111 October 2001 Artificial Intelligence LISP.
LISP: Power and Elegance in ONE. Overview n The History of Lips n Lisp, Mathematics and Elegance n The Power of Lisp n Lisp in Commercial Use.
COMP 205 – Week 11 Dr. Chunbo Chu. Intro Lisp stands for “LISt Process” Invented by John McCarthy (1958) Simple data structure (atoms and lists) Heavy.
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.
Allegro CL Certification Program Lisp Programming Series Level I Session Overview of Common Lisp.
LISP – Not just a Speech Impediment Jim Lowe. Brief History of LISP Initial development begins at the Dartmouth Summer Research Project in 1956 by Dr.
CSE S. Tanimoto Lisp Lisp S-Expressions: ATOMs Every Lisp object is either an ATOM or a CONS Symbols and numbers are kinds of atoms: X, APPLE,
Basic Lisp CIS 479/579 Bruce R. Maxim UM-Dearborn.
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.
TUTORIAL 1 CSCI3230 ( First Term) By Tony YI 1.
LISP John McCarthy and Marvin Minsky formed MIT’s AI Project in Suggested reading: John McCarthy’s home page
CS 326 Programming Languages, Concepts and Implementation Instructor: Mircea Nicolescu Lecture 5.
CSE (c) S. Tanimoto, 2002 AI Techniques 1 Where and When Do Symbols Refer to Values and Functions? Scope and Extent of Bindings Bindings Scope Extent.
CS 105: LISP GRG 424 MW 1:00-2:00pm About Me Jacob Schrum: call me Jacob BS in Computer Science, Math and German at Southwestern University Currently.
CS 331 Lisp/Scheme 1 Lisp/Scheme Ruth Rutter Functional and Logic Programming Team P-Phunck.
Scheme Profs Tim Sheard and Andrew Black CS 311 Computational Structures.
Milos Hauskrecht (PDF) Hieu D. Vu (PPT) LISP PROGARMMING LANGUAGE.
CSE S. Tanimoto More-Concepts - 1 More Programming Language Concepts Currying Lazy Evaluation Polymorphism.
Lisp "List Processing". Lisp history John McCarthy developed the basics behind Lisp during the 1956 Dartmouth Summer Research Project on Artificial Intelligence.
Introduction to LISP Atoms, Lists Math. LISP n LISt Processing n Function model –Program = function definition –Give arguments –Returns values n Mathematical.
CSE 341, S. Tanimoto Lisp LISP LISP = LISt Processing Intended for processing symbolic information Implementations from noncommercial sites: GNU.
CSE S. Tanimoto Lisps's Basic Functionality 1 LISP: Basic Functionality S-expressions Conses Lists Predicates Evaluation and quoting Conditional.
Functional Programming Part 1. Organization of Programming Languages-Cheng Big Picture u What we’ve learned so far: Imperative Programming Languages 
CSE 341, S. Tanimoto Lisp Explicit Application of Functions and Functional Arguments In Lisp, functions can be passed as arguments to other functions.
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.
Functional Programming
Functional Programming Languages
Functional Programming
PROGRAMMING LANGUAGES
CS 326 Programming Languages, Concepts and Implementation
LISP LISt Processing.
CSE S. Tanimoto Introduction
Lisp Tutorial Click on Xlisp icon – you enter the interpreter
LISP LISP = LISt Processing
CSE S. Tanimoto Introduction
CSE S. Tanimoto Explicit Function Application
CSE S. Tanimoto Introduction
Explicit Application of Procedures, and Explicit Evaluation
Lisp, Then and Now.
Lisp: Using Functions as Data
CSE S. Tanimoto Introduction
CSE S. Tanimoto Introduction
Lisp: Representation of Data
Defining Macros in Lisp
CSE (c) S. Tanimoto, 2002 Introducing Lisp
Defining Functions with DEFUN
LISP LISt Processing.
Abstraction and Repetition
Lisp: Using Functions as Data
Bindings, Scope, and Extent
LISP LISt Processing.
Modern Programming Languages Lecture 18 Fakhar Lodhi
Bindings, Scope, and Extent
Lisp: Representation of Data
Presentation transcript:

CSE S. Tanimoto Introduction 1 LISP Lisp is worth learning for the profound enlightenment experience you will have when you finally get it; that experience will make you a better programmer for the rest of your days, even if you never actually use Lisp itself a lot. -- Eric Raymond* * in How to Become a Hacker, quoted by Paul Graham (see the CSE 341 Syllabus page)

CSE S. Tanimoto Introduction 2 LISP Intentions and Implementations LISP = LISt Processing Intended for processing symbolic information Implementations from noncommercial sites: GNU Common Lisp (GCL) - U of Texas mods to Kyoto Common Lisp CLISP -- developed in Germany. Available implementations from Allegro Common Lisp for Windows, Web edition. Allegro Common Lisp for Linux

CSE S. Tanimoto Introduction 3 LISP: Our Objectives Motivation and History Interactive programming Functional programming List manipulation with recursive functions Polymorphism Language extensibility via macro definitions Closures (compare with objects) Language evolution to support multiple paradigms Lisp on the Web

CSE S. Tanimoto Introduction 4 History of Lisp (continued) John McCarthy, developed the ideas during the Dartmouth Summer Research Project on Artificial Intelligence, First implementation on the IBM 704 John McCarthy published “Recursive functions of symbolic expressions and their computation by machine” in Communications of the Association for Computing Machinery in 1960.

CSE S. Tanimoto Introduction 5 History of Lisp (continued) 1970s: advanced dialects -- MacLisp, InterLisp; Lisp machines (Symbolics, Inc.; Lisp Machines, Inc.; Xerox; Texas Instruments) Late 1970s: Scheme, Portable Standard Lisp, XLISP Common Lisp. Use of Lisp as internal scripting languages: Gnu Emacs, AutoCAD CLOS = Common Lisp Object System ANSI Standard Lisp.

CSE S. Tanimoto Introduction 6 Interacting with Lisp Interaction takes place in a Lisp Listener Window. Lisp runs an endless “ READ-EVAL-PRINT loop” for interacting with the user: READ EVAL PRINT

CSE S. Tanimoto Introduction 7 Interacting with Lisp (continued) > (+ 3 5) 8 > (* 2.5 (+ 2 2)) 10.0 > (setq x 5) 5 > (sqrt x) > (* x x) 25

CSE S. Tanimoto Introduction 8 Lisp’s Syntax Lisp uses one fundamental syntactic construct, the “symbolic expression” or S-expression. Any “atom” such as a number or a symbol, is an S- expression. Any parenthesized list of S-expressions, separated by whitespace, is an S-expression. A functional form is a list of the form (function-name arg1 arg2... argN) This is sometimes called parenthesized prefix form. (+ 3 5) (* 2.5 ( )) (sqrt x)

CSE S. Tanimoto Introduction 9 Parentheses in Lisp Every parenthesis in an S-expression has significance. (a b c) is different from (a (b c)) or ((a b) c). To call a zero-argument function, put its name in parentheses: (read) But not ((read)) The empty list can be denoted ( ) or NIL. Parentheses should always be balanced. (+ 3 (* 4 5) is an incomplete S-expression. Misplaced paren’s are a leading cause of beginners’ Lisp programming errors.

CSE S. Tanimoto Introduction 10 In-Class Exercise Convert the following mathematical expressions into Lisp’s parenthesized prefix form. a b. 5 x + 9 y + z c. 100 w / 7 mod 255 d. P and Q or R e. y = f(x + 1)

CSE S. Tanimoto Introduction 11 Defining a function > (* 5 5 5) 125 > (defun cube (n) (* n n n)) CUBE > (cube 2) 8 > (cube )

CSE S. Tanimoto Introduction 12 Symbolic Values Symbols are like identifiers, but they are commonly used as values as well as variables. > (setq x ’pizza) PIZZA > x PIZZA > (setq pizza ’pepperoni) PEPPERONI > pizza PEPPERONI > (eval x) PEPPERONI

CSE S. Tanimoto Introduction 13 More on Evaluation of Symbols > (setq x ’y) Y > (setq y ’z) Z > (setq z ’x) X > x Y > (eval x) Z > (eval (eval x)) X

CSE S. Tanimoto Introduction 14 Values of Symbols A symbol without a value in the current context is said to be “unbound”. The value of a symbol can be any Lisp object, including a number, another symbol, a functional object, a list, and array, etc. A symbol can have several local (“lexical”) values and one global value. However, symbols belong to “packages”, and two different packages can have symbols with the same name.