Download presentation
Presentation is loading. Please wait.
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 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 4.Instantiate an instance of this previous structure for the 1996 Los del Rio hit, Macarena, which plays for 3 minutes and 12 seconds. 5.Access the name of the song. 6.Access the playing-time of the song. 7.Declare an array that can hold 3 songs. 8.Assign the above structure to the second slot in the array.
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.