The Scheme Programming Language - PowerPoint PPT Presentation

About This Presentation
Title:

The Scheme Programming Language

Description:

In Scheme, 'car' returns the first element of a list and 'cdr' returns the ... cdr recursion is used as an iterator, moving from element to element in the list ... – PowerPoint PPT presentation

Number of Views:397
Avg rating:3.0/5.0
Slides: 17
Provided by: Dima154
Category:

less

Transcript and Presenter's Notes

Title: The Scheme Programming Language


1
The Scheme Programming Language
  • History and Significance
  • Dmitry Nesvizhsky
  • CIS24
  • Professor Danny Kopec

2
Scheme History
  • Started as an experiment in programming language
    design by challenging some fundamental design
    assumptions
  • A dialect of the LISP Programming Language
    invented by Guy Lewis Steele Jr. and Gerald Jay
    Sussman

3
Scheme History
  • Emerged from MIT in the mid-1970's
  • Originally called Schemer
  • Shortened to Scheme because of a 6 character
    limitation on file names
  • Designed to have very few regular constructs
    which compose well to support a variety of
    programming styles
  • Functional, object-oriented, and imperative

4
Significant Language Features
  • Supports lexical scoping, uniform evaluation
    rules, and uniform treatment of data types
  • Does not support the concept of a pointer,
    uninitialized variables, specialized looping
    constructs, or explicit storage management
  • All data type are equal
  • What one can do to one data type, one can do to
    all data types

5
Significant Language Features
  • There are seven kinds of expressions
  • Constant
  • Variable reference
  • Procedure creation
  • Procedure application
  • Conditional
  • Assignment
  • Sequence

6
Significant Language Features
  • Scheme also has the usual assortment of data
    types
  • Characters
  • Strings
  • Arrays
  • Lists
  • Numbers
  • Functions (also called procedures)
  • Boolean
  • Ports
  • Symbols

7
Significant Language Features
  • Numbers are especially interesting
  • An integer is a rational and a real is a complex
  • Scheme requires no looping constructs
  • Any function which calls itself in the "tail"
    position is just a loop

8
Significant Language Features
  • Scheme has several important advantages
  • It is elegantly simple in that regular structure
    and trivial syntax avoids "special case"
    confusion
  • Its expressiveness means that one spends little
    time trying to work around the language
  • It lets users concentrate on what they want to
    say rather than on how to say it

9
Significant Language Features
  • Scheme has several important advantages
    (continued)
  • Supports a variety of styles (including
    object-oriented)
  • Allows users to better match their solution style
    to the style of the problems to be solved
  • Its formal underpinnings make reasoning about
    programs much easier

10
Significant Language Features
  • Scheme has several important advantages
    (continued)
  • Its abstractive power makes it easy to separate
    system specific optimizations from reusable code
  • Its compos ability makes it easy to construct
    systems from well-tested components

11
Areas of Application
  • Scheme is currently gaining favor as a first
    programming language in universities and is used
    in industry by such companies as TI, HP, and Sun

12
Areas of Application
  • Here are a few statistics regarding the schools
    using Scheme
  • 286 colleges/universities worldwide - 108 of
    these use Scheme in introductory courses
  • 159 colleges/universities USA only - 49 of these
    use Scheme in introductory courses
  • 73 secondary schools worldwide
  • 64 secondary schools USA only

13
Sample Program 1
  • This program prints the phrase "Hello World
  • indigo_at_owlnet.rice.edu (Scott Ruthfield)
  • (define hello-world
  • (lambda ()
  • (begin
  • (write Hello-World)
  • (newline)
  • (hello-world))))

14
Sample Program 2
  • Scheme is an imperative language that favors
    recursion over iteration
  • The basic data structure is the list
  • In Scheme, "car" returns the first element of a
    list and "cdr" returns the remaining elements of
    the list
  • There is no need for an "iterator class" or
    pointers, as in C
  • In this program cdr recursion is used as an
    iterator, moving from element to element in the
    list
  • The result from each recursive call becomes the
    input, or term, for the addition operator, there
    by eliminating the need for a temporary sum
    variable

15
Sample Program 2 (continued)
  • List Sum
  • This program was found in "An Introduction to
  • Scheme" by Jerry Smith, Prentice Hall, 1988
  • (define
  • (list-sum lst)
  • (cond
  • ((null? lst) 0)
  • ((pair? (car lst))
  • ((list-sum (car lst)) (list-sum (cdr lst))))
  • (else
  • ( (car lst) (list-sum (cdr lst))))))

16
Scheme Performance Table
Write a Comment
User Comments (0)
About PowerShow.com