Common Lisp! John Paxton Montana State University Summer 2003
Montana National Parks Yellowstone Glacier
Structure Declaration (defstruct city name country (population ) )
Structure Creation > (setf san-salvador (make-city)) #S(CITY :NAME NIL :COUNTRY NIL :POPULATION ) > (setf bozeman (make-city :population 30000)) #S(CITY :NAME NIL :COUNTRY NIL :POPULATION 30000)
Field Access > (setf (city-country san-salvador) 'el-salvador) EL-SALVADOR
Useful Predicates > (city-p san-salvador) T > (describe san-salvador) #S(CITY :NAME NIL :COUNTRY EL-SALVADOR :POPULATION ) is a structure of type CITY. Slots: NAME = NIL COUNTRY = EL-SALVADOR POPULATION = and more!
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.
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.