Common Lisp! - PowerPoint PPT Presentation

About This Presentation
Title:

Common Lisp!

Description:

S(CITY :NAME NIL :COUNTRY EL-SALVADOR :POPULATION 100000) is a structure of type ... COUNTRY = EL-SALVADOR. POPULATION = 100000 and more! Questions ... – PowerPoint PPT presentation

Number of Views:34
Avg rating:3.0/5.0
Slides: 9
Provided by: Joh7
Category:
Tags: common | el | lisp | salvador

less

Transcript and Presenter's Notes

Title: Common Lisp!


1
Common Lisp!
  • John Paxton
  • Montana State University
  • Summer 2003

2
Montana National Parks
  • Yellowstone
  • Glacier

3
Structure Declaration
  • (defstruct city
  • name
  • country
  • (population 100000)
  • )

4
Structure Creation
  • gt (setf san-salvador (make-city))
  • S(CITY NAME NIL COUNTRY NIL POPULATION
    100000)
  • gt (setf bozeman (make-city population 30000))
  • S(CITY NAME NIL COUNTRY NIL POPULATION 30000)

5
Field Access
  • gt (setf (city-country san-salvador)
  • 'el-salvador)
  • EL-SALVADOR

6
Useful Predicates
  • gt (city-p san-salvador)
  • T
  • gt (describe san-salvador)
  • S(CITY NAME NIL COUNTRY EL-SALVADOR
    POPULATION 100000) is a structure of type CITY.
  • Slots
  • NAME NIL
  • COUNTRY EL-SALVADOR
  • POPULATION 100000 and more!

7
Questions
  1. Declare a structure called playing-time that can
    hold the number of minutes and seconds that a
    song lasts.
  2. Instantiate an instance of the above structure
    that plays for 3 minutes and 42 seconds.
  3. Declare another structure called song that can
    hold the name of a song and its playing-time.

8
Questions
  1. Instantiate an instance of this previous
    structure for the 1996 Los del Rio hit, Macarena,
    which plays for 3 minutes and 12 seconds.
  2. Access the name of the song.
  3. Access the playing-time of the song.
  4. Declare an array that can hold 3 songs.
  5. Assign the above structure to the second slot in
    the array.
Write a Comment
User Comments (0)
About PowerShow.com