It is suggested that you use the Lisp interpreter available on the general machine (general.asu.edu). You are welcome to use other interpreters while developing,

Slides:



Advertisements
Similar presentations
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.
Advertisements

ANSI Common Lisp 5. Control 16 June Blocks -- progn progn > (progn (format t “a”) (format t “b”) ( )) ab 23 The expressions within its body.
Lisp II. How EQUAL could be defined (defun equal (x y) ; this is how equal could be defined (cond ((numberp x) (= x y)) ((atom x) (eq x y)) ((atom y)
1 Programming Languages and Paradigms Lisp Programming.
Lisp II. How EQUAL could be defined (defun equal (x y) ; this is how equal could be defined (cond ((numberp x) (= x y)) ((atom x) (eq x y)) ((atom y)
Chapter 3 Functional Programming. Outline Introduction to functional programming Scheme: an untyped functional programming language.
Lisp Recitation (cse471/598 Fall 2007 ) Aravind Kalavagattu.
PZ10CX Programming Language design and Implementation -4th Edition Copyright©Prentice Hall, PZ10CX - LISP Programming Language Design and Implementation.
Functional Programming COMP2003 A course on functional programming using Common Lisp Dr Eleni Mangina
© Copyright 1992–2005 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. Tutorial 14 – Student Grades Application: Introducing.
ITERATIVE CONSTRUCTS: DOLIST Dolist is an iterative construct (a loop statement) consisting of a variable declaration and a body The body states what happens.
Introduction to Artificial Intelligence Lisp Ruth Bergman Fall 2002.
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)
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.
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.
Agenda What is Computer Programming? The Programming Process
Input/Output Chapters 7 & 9. Output n Print produces output > (print 100) n It also returns the value it printed –that’s where the second 100 came.
The Case primitive: matches the evaluated key form against the unevaluated keys by using eql The general format of case is the following: (case (... ).....
Introduction to Computational Linguistics Programming I.
Basic Lisp CIS 479/579 Bruce R. Maxim UM-Dearborn.
1 Lisp Functions –Built-in functions –Defining functions –Function Evaluation and Special Forms defun, if Control statements –Conditional if, cond –Repetition.
Common lisp A functional programming language. Useful URL:
Shell Script Programming. 2 Using UNIX Shell Scripts Unlike high-level language programs, shell scripts do not have to be converted into machine language.
06 INPUT AND OUTPUT Functional Programming. Streams Two kinds of streams  Character streams  Binary streams Character streams are Lisp objects representing.
ISU Basic SAS commands Laboratory No. 1 Computer Techniques for Biological Research Animal Science 500 Ken Stalder, Professor Department of Animal Science.
Compiling a C Program. Before we can begin we must open a telnet session to phobos. There are a number of ways to do this, but the easiest is to click.
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 Files, Arrays, and Macros CIS 479/579 Bruce R. Maxim UM-Dearborn.
ENG College of Engineering Engineering Education Innovation Center 1 More Script Files in MATLAB Script File I/O : Chapter 4 1.Global Variables.
CS535 Programming Languages Chapter - 10 Functional Programming With Lists.
UMBC CMSC Common Lisp II. UMBC CMSC Input and Output Print is the most primitive output function > (print (list 'foo 'bar)) (FOO BAR) The.
PRACTICAL COMMON LISP Peter Seibel 1.
Control Structures RepetitionorIterationorLooping Part I.
Milos Hauskrecht (PDF) Hieu D. Vu (PPT) LISP PROGARMMING LANGUAGE.
A First Book of C++: From Here To There, Third Edition2 Objectives You should be able to describe: The while Statement cin within a while Loop The for.
A FIRST BOOK OF C++ CHAPTER 5 REPETITION. OBJECTIVES In this chapter, you will learn about: The while Statement Interactive while Loops The for Statement.
A First Book of C++ Chapter 5 Repetition.
Control Structures CSC 358/ Outline Midterm Lab #3 Homework #4 Sequential structures Conditional structures Unconditional branching Iteration.
C H A P T E R E I G H T Functional Programming Programming Languages – Principles and Paradigms by Allen Tucker, Robert Noonan.
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.
 If you want to open an already existing file select file->open on the menu and then choose the program you want to modify. If you want to open a new.
1 Outline Review Introduction to LISP Symbols and Numbers Lists Writing LISP Functions LISPWorks.
Artificial Intelligence and Lisp Lecture 6 LiU Course TDDC65 Autumn Semester,
ECE Application Programming
The Python interpreter
Organization of Programming Languages
CS 326 Programming Languages, Concepts and Implementation
Getting Started with Lisp
LISP LISt Processing.
CHAPTER 4 CLIENT SIDE SCRIPTING PART 2 OF 3
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.
When I want to execute the subroutine I just give the command Write()
Alternate Version of STARTING OUT WITH C++ 4th Edition
The Python interpreter
A First Book of ANSI C Fourth Edition
Lisp Tutorial Click on Xlisp icon – you enter the interpreter
Chapter 2.1 Repetition.
Modern Programming Languages Lecture 20 Fakhar Lodhi
LISP A brief overview.
Objectives You should be able to describe: The while Statement
Defining Functions with DEFUN
LISP LISt Processing.
Abstraction and Repetition
LISP LISt Processing.
Modern Programming Languages Lecture 18 Fakhar Lodhi
Common Lisp II.
Programming Languages
The general format of case is the following: (case <key form>
Presentation transcript:

It is suggested that you use the Lisp interpreter available on the general machine (general.asu.edu). You are welcome to use other interpreters while developing, but your programs should run on the general for grading purposes. If you absolutely must use a different version and find that your version is not compatible with the version on the general, contact the TA before you turn in any work and make alternate arrangements. Getting Started with Lisp

Lisp on the General  Allegro Common Lisp is available on the general. The general is the “general purpose” Unix account all ASU students have access to. You can access it with telnet or (better) ssh, at general.asu.edu. Once you logon to the general, you will get a Unix prompt. At the prompt, type in the command “cl” to start Common Lisp.

The Lisp Prompt Lisp is an interactive, interpreted language. You can interact with it by entering commands at its command prompt, or by telling it to read in a file of commands. Every command entered, either at the prompt or read from a file, is immediately evaluated and executed by the interpreter.

Basic Commands (exit) or :exit - Exits the Lisp interpreter (load “file”) – Loads and evaluates a file. Ctrl+C – Breaks execution if you get stuck. :help – Shows list of interpreter commands :reset – Starts the interpreter over :pop – Goes up one level of error breaks

Manipulating Lists Using Quote:- e.g.: USER(1): ‘(1 2 3) (1 2 3) Using CAR:- e.g.: USER(2): CAR( ) 1 Using CDR:- e.g.:- USER(3): CDR( 1 2 3) ( 2 3)

Using Lists II Cons – (cons a b) – Creates a new list with a head of a and a tail of b e.g. (cons ‘a ‘(b c)) gives (a b c) Append – (append a b …) – Creates a new list out of a set of lists e.g. (append '(a b c) '() '(d e f)) gives (a b c d e f)

RECURSION LISP supports recursion just like any procedural language(eg: C) E.g.: Raise X to the Nth power (defun raise (x n) (if (= n 0) 1 (* x ( raise x (- n 1) ) ) ) )

ITERATION Using dolist :- dolist repeats a set of operations for as many times as there are entries in a list. E.g.:-USER(1): (dolist (x ‘(a b c)) (print x)) A B C NIL

Using LOOP E.g.:- USER(15):- (loop for x from 1 to 7 collect x) ( )

Conditional Expressions:- Using CASE. E.g.:- User(10):(defun goose (x) (case x (1 ‘one) (2 ‘two) (3 ‘three) (4 ‘four) (otherwise ‘many))) goose

Using dotimes :- dotimes repeats an evaluation as many times as it is requested E.g.:- USER(10):-(dotimes (i 5 i) (print i) o

Defining functions using “defun” USER(1):(defun funct1 (x) (+ x 1)) FUNCT1 USER(2):(funct1(3)) 4

Input and Output > (progn (format t “Please enter your name: ”) (read-line)) > (prin1 “hello”) > (format nil “Dear ~A, ~% Our records indicate …” “Mr. Malatesta”) Note: There are many variants. You need to refer to a CL book.

Other Resources is a Lisp primer. The “Programming Techniques” section should be checked out. has the complete text of the 2 nd edition of Common Lisp the Language.