Common Lisp! John Paxton Montana State University Summer 2003.

Slides:



Advertisements
Similar presentations
CS 63 LISP Philip Greenspun's Tenth* Rule of Programming:
Advertisements

ANSI Common Lisp 3. Lists 20 June Lists Conses List Functions Trees Sets Stacks Dotted Lists Assoc-lists.
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.
Ordinal Numbers. Order 1,2,3,4,5,6,7,8 These numbers are in order. 1,2,4,6,5,8,7 These numbers are not in order.
Math Ordinal Positions Grade 2 SOL 2.3 Created by; Kim Smith.
Let’s repeat the ordinal numbers!
1 Programming Languages and Paradigms Lisp Programming.
Type Title Here for Tic-Tac-Toe Type names of students in group here.
CS 355 – PROGRAMMING LANGUAGES Dr. X. Apply-to-all A functional form that takes a single function as a parameter and yields a list of values obtained.
Common Lisp! John Paxton Montana State University Summer 2003.
KS3 Mathematics N4 Powers and roots
1 Introduction of Lisp function e.g. (+ 2 2) Shift+Enter Execute …… (+ 1 2) 3 ( ) 15 (- 1 6) -5 ( ) -5 (- ( ) (+
Lisp – Introduction יעל נצר מערכות נבונות סמסטר ב' תשס"ו.
Common Lisp! John Paxton Montana State University Summer 2003.
First Lecture on Introductory Lisp Yun Peng. Why Lisp? Because it’s the most widely used AI programming language Because AI researchers and theoreticians.
Common Lisp! John Paxton Montana State University Summer 2003.
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.
Chapter 15 Functional Programming Languages. Copyright © 2007 Addison-Wesley. All rights reserved. 1–2 Introduction Design of imperative languages is.
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)
Introductory Lisp Programming Lecture # 2 Main Topics –Basic Lisp data types –Lisp primitives –Details of list handling Cons cells (boxes) & their representation.
Programming in Lisp; Instructor: Alok Mehta Programming in Lisp Recursion, Data Abstraction, Mapping, Iteration.
CSCI Programming in Lisp; Instructor: Alok Mehta1 CSCI 2210: Programming in Lisp Introduction to Lisp.
LISP A brief overview. Lisp stands for “LISt Process” –Invented by John McCarthy (1958) –Simple data structure (atoms and lists) –Heavy use of recursion.
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 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.
Yu-Tzu Lin ( 林育慈 )
CS 462: Introduction to Artificial Intelligence This course advocates the physical-symbol system hypothesis formulated by Newell and Simon in It.
PRACTICAL COMMON LISP Peter Seibel 1.
A First Book of ANSI C Fourth Edition
For Monday Read Chapter 3 Homework: –Lisp handout 2.
1 Lisp Functions –Built-in functions –Defining functions –Function Evaluation and Special Forms defun, if Control statements –Conditional if, cond –Repetition.
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.
Topics in Artificial Intelligence: Intelligent Problem Solvers This course is about building systems that can reason -- that is, solve problems by utilizing.
Introduction to Engineering MATLAB – 2 Introduction to MATLAB - 2 Agenda Defining Variables MATLAB Windows.
Function Design in LISP. Program Files n LISP programs are plain text –DOS extensions vary; use.lsp for this course n (load “filename.lsp”) n Can use.
Predicates, Functions and Files "I suppose I should learn Lisp, but it seems so foreign." - Paul Graham, Nov 1983.
Programming in Lisp; Instructor: Alok Mehta Programming in Lisp Introduction to Lisp.
LISP Data Types Functional Programming Academic Year Alessandro Cimatti
K - 2 © 2012 Math As A Second Language All Rights Reserved Ordinal Numbers 1 – 10 and beyond with the Adjective/ Noun next.
Multiplying Common Fractions Multiplying next Using the Corn Bread © Math As A Second Language All Rights Reserved.
You can access the members of a list with the functions car (or first) and cdr (or rest): (setf list '(a b c)) (car list) ⇒ a (first list) ⇒ a (cdr list)
Operating on Lists Chapter 6. Firsts and Seconds n Transforming list of pairs into two lists –(firsts ‘((1 5) (2 6) (3 7)))  (1 2 3) –(seconds ‘((1 5)
Happy New Year 2012 The top ten New Year’s Resolutions.
Introduction to LISP Atoms, Lists Math. LISP n LISt Processing n Function model –Program = function definition –Give arguments –Returns values n Mathematical.
Form 1 Mathematics Chapter 2 and Chapter 4. Ronald HUI  “>”: Greater than  “
Fractions Part Two. How many halves are in a whole? 2 1/2.
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.
1 Outline Review Introduction to LISP Symbols and Numbers Lists Writing LISP Functions LISPWorks.
LISP – (LISt Processing)
Zoom In Game.
Example of formula (defun roots (a b c) (list
Adding Like Fractions Adding Like Fractions
Ordinal Numbers Helen Browne Maureen Phillips Phyllis Spencer.
LISP LISt Processing.
LISP A brief overview.
Number Words 1st Grade.
First Lecture on Introductory Lisp
Modern Programming Languages Lecture 21 Fakhar Lodhi
Student #7 starts with Locker 7 and changes every seventh door
CS 36 – Chapter 11 Functional programming Features Practice
LISP A brief overview.
John McCarthy Pioneer in AI Also Lisp Formalize common-sense reasoning
Ms. Lindsey’s Kindergarten Class 11/1/16
LISP LISt Processing.
LISP LISt Processing.
Modern Programming Languages Lecture 18 Fakhar Lodhi
EET 2259 Unit 8 Other Structures; Local Variables
CS 462: Introduction to Artificial Intelligence
LISP primitives on sequences
Presentation transcript:

Common Lisp! John Paxton Montana State University Summer 2003

Textbook Lisp, 3 rd Edition Winston, Horn Addison-Wesley 1989

Where is Montana?

Where is Bozeman?

Why Lisp? Interpreted environment Editing and debugging tools Built on many years of experience Code and data have same form Lisp = List Processing

Lisp Myths It’s slow Programs are large Requires expensive computers Hard to read Hard to learn

Terminology atom, e.g. 1 list, e.g. ‘(1 2 3) s-expression

Comment ;; Line comments start with two semicolons.

first > (first '(1 2 3)) 1 second, third, fourth, fifth, sixth, seventh, eighth, ninth, tenth

rest > (rest '(1 2 3)) (2 3) > (rest 'apple) *** - REST: APPLE is not a list

setf > (setf location 'san-salvador) SAN-SALVADOR > location SAN-SALVADOR

cons > (cons 1 '(2 3)) (1 2 3) > (cons '(1) '(2 3)) ((1) 2 3)

append > (append '(1) '(2 3)) (1 2 3) > (append 1 '(2 3)) *** - APPEND: 1 is not a list (append '(1) 2) (1. 2)

list > (list 1) (1) > (list ) ( )

length > (length 'apple) *** - LENGTH: APPLE is not a sequence > (length '( )) 4

reverse > (reverse '(1 2 3)) (3 2 1) > (reverse '((1 2) 3)) (3 (1 2))

assoc > (assoc 'mister '((miss senorita) (mister senor))) (MISTER SENOR)

nthcdr (nthcdr 0 '(1 2 3)) (1 2 3) > (nthcdr 1 '(1 2 3)) (2 3) > (nthcdr 4 '(1 2 3)) NIL

butlast > (butlast '(1 2 3) 0) (1 2 3) > (butlast '(1 2 3) 1) (1 2) > (butlast '(1 2 3) 4) NIL

last > (last '(1 2 3)) (3)

Mathematical Operators + - * / > (+ 2 (* 3 4)) 14

Mathematical Functions round float max min expt sqrt abs

Questions 1.How do you invoke CLISP? 2.How do you exit CLISP? 3.What happens when you enter 5? 4.What happens when you enter ‘vertigo? 5.What happens when you enter vertigo? 6.What happens when you enter ‘(vertigo notorious).

Questions 7.What happens when you enter (vertigo notorious) ? 8.Give the variable movies the value ‘(vertigo notorious). 9.Access the first element of movies. 10.Access all of the elements of movies except for the first element. 11.What is t? What is nil?

Questions 12.Add spellbound to the front of movies. 13.Add spellbound to the end of movies. 14.Use list, append, and cons to build the list ‘(plantain guava). 15.Determine how many items are in movies. 16.Change movies so that the movies are listed in reverse order.

Questions 17.Calculate the sum of 2 plus Calculate the sum of 2 plus 3 plus Write an expression that uses the quadratic formula to calculate one of the roots of x 2 + x – 6 = What happens when you make an error? 21.How do you recover from an error?