1 / 8

Common Lisp!

Common Lisp!. John Paxton Montana State University Summer 2003. Montana National Parks. Yellowstone Glacier. Structure Declaration. (defstruct city name country (population 100000) ). Structure Creation. > (setf san-salvador (make-city))

kelle
Download Presentation

Common Lisp!

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  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 > (setf san-salvador (make-city)) #S(CITY :NAME NIL :COUNTRY NIL :POPULATION 100000) > (setf bozeman (make-city :population 30000)) #S(CITY :NAME NIL :COUNTRY NIL :POPULATION 30000)

  5. Field Access > (setf (city-country san-salvador) 'el-salvador) EL-SALVADOR

  6. Useful Predicates > (city-p san-salvador) T > (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 • Declare a structure called playing-time that can hold the number of minutes and seconds that a song lasts. • Instantiate an instance of the above structure that plays for 3 minutes and 42 seconds. • Declare another structure called song that can hold the name of a song and its playing-time.

  8. Questions • Instantiate an instance of this previous structure for the 1996 Los del Rio hit, Macarena, which plays for 3 minutes and 12 seconds. • Access the name of the song. • Access the playing-time of the song. • Declare an array that can hold 3 songs. • Assign the above structure to the second slot in the array.

More Related