### Rules to create a 365-day calendar. ### This version creates only 1 day per month because ### the name attribute is attached to the year. ### Also, in this production the value of 2003 is actually attached ### to the state, not the year. If there is to be only one year in the ### calendar, this might not matter, but if there are to be more years, ### then the value needs to be attached to the year object to keep ### everything straight. sp {initialize*calendar (state ^superstate nil) --> ( ^year ^value 2003)} sp {initialize*months (state ^year ) --> ( ^month ^name january) ( ^month ^name february) ( ^month ^name march) ( ^month ^name april) ( ^month ^name may) ( ^month ^name june) ( ^month ^name july) ( ^month ^name august) ( ^month ^name september) ( ^month ^name october) ( ^month ^name november)} sp {initialize*31day*length (state ^year ) ( ^month ) ( ^name << january march may july august october december >> ) --> ( ^days 31)} sp {initialize*30day*length (state ^year ) ( ^month ) ( ^name << september april june november >> ) --> ( ^days 30)} sp {initialize*february*length (state ^year ) ( ^month ) ( ^name february) --> ( ^days 28)} sp {initialize*first*days (state ^year ) ( ^month ) --> ( ^date 1)} sp {initialize*remaining*days (state ^year ) ( ^month ) ( ^days ) ( ^date { < } ) --> ( ^date ( + 1 ))}