CSE S. Tanimoto Introduction

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 Scheme and Functional Programming Aaron Bloomfield CS 415 Fall 2005.
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.
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.
CSE S. Tanimoto Introduction 1 LISP Lisp is worth learning for the profound enlightenment experience you will have when you finally get it; that.
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.
Basic Lisp CIS 479/579 Bruce R. Maxim UM-Dearborn.
CSE 341, S. Tanimoto Lisp Defining Functions with DEFUN Functions are the primary abstraction mechanism available in Lisp. (Others are structures.
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.
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.
CSE 341, S. Tanimoto Lisp LISP LISP = LISt Processing Intended for processing symbolic information Implementations from noncommercial sites: GNU.
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
Lisp S-Expressions: ATOMs
Defining Macros in Lisp
CS 326 Programming Languages, Concepts and Implementation
LISP LISt Processing.
CSE S. Tanimoto Introduction
Lisp Tutorial Click on Xlisp icon – you enter the interpreter
CSE 341 Programming Languages Autumn 2003
LISP LISP = LISt Processing
CSE 341 Programming Languages Autumn 2002
Scheme: Basic Functionality
CSE S. Tanimoto Explicit Function Application
CSE S. Tanimoto Introduction
Explicit Application of Procedures, and Explicit Evaluation
Functional Programming Concepts
Lisp, Then and Now.
Lisp: Using Functions as Data
CSE 341 Programming Languages Spring 2003
CSE S. Tanimoto Introduction
CSE S. Tanimoto Introduction
Functional Programming Concepts
Lisp: Representation of Data
Defining Macros in Lisp
CSE 341 Programming Languages Autumn 2003
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: Basic Functionality
LISP LISt Processing.
Modern Programming Languages Lecture 18 Fakhar Lodhi
Functional Programming Concepts
LISP: Basic Functionality
Bindings, Scope, and Extent
LISP: Basic Functionality
Defining Macros in Scheme
Lisp: Representation of Data
Presentation transcript:

CSE 341 -- S. Tanimoto Introduction 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 341 -- S. Tanimoto Introduction

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 www.franz.com: Allegro Common Lisp for Windows, Web edition. Allegro Common Lisp for Linux CSE 341 -- S. Tanimoto Introduction

CSE 341 -- S. Tanimoto Introduction 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 341 -- S. Tanimoto Introduction

History of Lisp (continued) John McCarthy, developed the ideas during the Dartmouth Summer Research Project on Artificial Intelligence, 1956. 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 341 -- S. Tanimoto Introduction

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. 1984. Common Lisp. Use of Lisp as internal scripting languages: Gnu Emacs, AutoCAD. 1987 CLOS = Common Lisp Object System. 1994 ANSI Standard Lisp. CSE 341 -- S. Tanimoto Introduction

CSE 341 -- S. Tanimoto Introduction 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 341 -- S. Tanimoto Introduction

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

CSE 341 -- S. Tanimoto Introduction 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 (+ 2 2 7)) (sqrt x) CSE 341 -- S. Tanimoto Introduction

CSE 341 -- S. Tanimoto Introduction 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 341 -- S. Tanimoto Introduction

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

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

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

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

CSE 341 -- S. Tanimoto Introduction 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. CSE 341 -- S. Tanimoto Introduction