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 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.
Peter Seibel Practical Common Lisp Peter Seibel
1 Functional programming Languages And a brief introduction to Lisp and Scheme.
Introduction to Artificial Intelligence Lisp Ruth Bergman Fall 2002.
Functional programming: LISP Originally developed for symbolic computing Main motivation: include recursion (see McCarthy biographical excerpt on web site).
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)
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.
Functional programming: LISP Originally developed for symbolic computing First interactive, interpreted language Dynamic typing: values have types, variables.
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: 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.
Presentation topic : LISP Amir Shahzad MCS 3 MCC
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.
Functional Programming in Scheme and Lisp. Overview In a functional programming language, functions are first class objects. You can create them, put.
CSE S. Tanimoto Lambda Calculus 1 Lambda Calculus What is the simplest functional language that is still Turing complete? Where do functional languages.
Λ => Scheme for Rubyists. Scheme History Authors: Guy Steele and Gerald Sussman Structure and Interpretation of Computer Programs (SICP) by Abelson &
Copyright © 2007 Addison-Wesley. All rights reserved.1-1 Reasons for Studying Concepts of Programming Languages Increased ability to express ideas Improved.
CS 326 Programming Languages, Concepts and Implementation Instructor: Mircea Nicolescu Lecture 5.
CSE S. Tanimoto Macros 1 Defining Macros in Scheme Extensibility: A language is extensible if the language can be extended. New Scheme control structures.
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.
1-1 An Introduction to Functional Programming Sept
Scheme Profs Tim Sheard and Andrew Black CS 311 Computational Structures.
Milos Hauskrecht (PDF) Hieu D. Vu (PPT) LISP PROGARMMING LANGUAGE.
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.
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
CS 3304 Comparative Languages
Why study programming languages?
PROGRAMMING LANGUAGES
Defining Macros in Lisp
CS 326 Programming Languages, Concepts and Implementation
LISP LISt Processing.
CSE 341 Programming Languages Autumn 2001
CSE 341 Programming Languages Autumn 2003
LISP LISP = LISt Processing
CSE 341 Programming Languages Autumn 2002
Scheme: Basic Functionality
Bindings, Scope, and Extent
CSE S. Tanimoto Introduction
CSE S. Tanimoto Introduction
Explicit Application of Procedures, and Explicit Evaluation
Delayed Evaluation Special forms in Scheme (e.g., if and cond) do not use applicative order evaluation Only one of two or more expressions is actually.
Lisp and Scheme I.
Lisp, Then and Now.
CSE 341 Programming Languages Spring 2003
CSE S. Tanimoto Introduction
CSE 3302 Programming Languages
CSE S. Tanimoto Introduction
Defining Macros in Lisp
CSE 341 Programming Languages Autumn 2003
CSE (c) S. Tanimoto, 2002 Introducing Lisp
LISP LISt Processing.
Abstraction and Repetition
Bindings, Scope, and Extent
LISP LISt Processing.
CSE S. Tanimoto Lambda Calculus
Modern Programming Languages Lecture 18 Fakhar Lodhi
Bindings, Scope, and Extent
Chapter 15 Functional Programming 6/1/2019.
Defining Macros in Scheme
A Programming Language for
Presentation transcript:

CSE 341 -- S. Tanimoto Introduction Scheme Scheme is a dialect of 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 and Scheme Implementations LISP = LISt Processing (Intended for processing symbolic information) Lisp implementations from noncommercial sites: GNU Common Lisp (GCL) - U of Texas mods to Kyoto Common Lisp CLISP -- developed in Germany. Lisp implementations from www.franz.com: Allegro Common Lisp for Windows, Web edition. Allegro Common Lisp for Linux DrScheme: MzScheme with a GUI. (free) Cadence Research: Chez Scheme (commercial version) Petite Chez Scheme (free interp. w/out compiler) CSE 341 -- S. Tanimoto Introduction

Scheme: Our Objectives Motivation and History Interactive programming Functional programming List manipulation with recursive functions Polymorphism Language extensibility via macro definitions Closures (compare with objects) Scheme on the Web CSE 341 -- S. Tanimoto Introduction

History of Lisp and Scheme 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 & Scheme (continued) 1970s: advanced dialects -- MacLisp, InterLisp; Lisp machines (Symbolics, Inc.; Lisp Machines, Inc.; Xerox; Texas Instruments) 1975: Scheme. Late 1970s: Portable Standard Lisp, XLISP. 1984. Common Lisp. Use of Lisp as internal scripting languages: Gnu Emacs, AutoCAD. 1987 CLOS = Common Lisp Object System. 1991 IEEE Standard approved for Scheme. 1991 Revised4 Report for Scheme. 1994 ANSI Standard Lisp. 1990s - Scheme as scripting lang. in the GIMP. CSE 341 -- S. Tanimoto Introduction

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

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

CSE 341 -- S. Tanimoto Introduction Scheme’s Syntax Scheme 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 procedural form is a list of the form (procedure-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 Scheme 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 is denoted ( ). Parentheses should always be balanced. (+ 3 (* 4 5) is an incomplete S-expression. Misplaced paren’s are a leading cause of beginners’ Scheme programming errors. CSE 341 -- S. Tanimoto Introduction

CSE 341 -- S. Tanimoto Introduction In-Class Exercise Convert the following mathematical expressions into Scheme’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 > (define (cube n) (* n n n)) > (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. > (define x ’pizza) > x PIZZA > (define pizza ’pepperoni) > pizza PEPPERONI > (eval x) CSE 341 -- S. Tanimoto Introduction

More on Evaluation of Symbols > (define x ’y) > (define y ’z) > (define z ’x) > x Y > (eval x) Z > (eval (eval x)) 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 Scheme object, including a number, another symbol, a procedure, 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