define lines(stat); vars line; foreach [[?line ^^stat] connects =] do line => endforeach; foreach [= connects [?line ^^stat]] do line => endforeach; enddefine; lines([Green Park]);
Why is the second half of this procedure necessary?
Write a procedure that prints out all the names of the stations on a given line. Modify it so that instead of printing the information, the station names are returned in a list. Do not worry if a station name appears more than once in the list. (It is quite easy to write a procedure that will remove the extra occurrences.)
Your program will probably proceed by trying different combinations of blocks -- i.e., by effectively asking questions like ``What if the tower includes the block of height 7?'' The program might use the database to store information about which blocks are available and which ones have been tried. This program may be rather easier when you know more POP-11, so you may want to return to it when you have read further along in the book.