Index: Lab basics, Register, Netscape, News, DrScheme, Simple data definitions
All labs are held in Ryon 102 (the southwest corner); all will be held in the back section.
Sections:
The labs for Comp210 complement the lecture. The labs focus on providing additional examples and hands-on work to reinforce the lecture.
Also, the labs cover utilitarian details not covered in lecture, such as how to use different software packages and (later in the semester) aspects of C syntax. These topics are important for doing the homework, but would be distracting from the overall flow of the lectures.
There will be weekly lab web pages, but no assignments beyond the homeworks distributed in lecture.
After each weekly lab session, be sure to look over that lab's web page: most of the material will be familiar from lab, but sometimes there isn't enough time in lab to cover every topic. You may be held responsible for knowing any information which is on the lab web pages.
First, we need to "register" for this course. This will tweak your computing environment to simplify access to the course tools. In one of the xterm windows, type register comp210 (followed by the Return key). Answer y (yes) to the questions it asks.
For most of these changes to have effect, log out and then log in again. The most visible change is that there is now a small menu for Comp 210 on your screen.
registering is not necessary, but should be done unless you
are very familiar with UNIX. This command alters several files,
including your .cshrc and .twmrc, adding
things to your
If you have a problem registering, you probably have changed your windowing environment substantially from the Owlnet default. Talk to a labby or Mudd consultant after lab.
Netscape is a window-based program that displays hypertext documents from the World-Wide Web (or Web, for short). Hypertext documents can contain text, pictures, sound, movies, and (perhaps most importantly) links to other documents. The World-Wide Web (WWW) is an interconnected collection of these hypertext documents. The act of browsing the Web of documents is called "Web surfing" or "net surfing."
To run Netscape, either
The first time that you use Netscape, it will display a license agreement. Read it and click on the Accept button. Netscape will then display a window stating your account has not yet been initialized for Netscape. Click on the OK button to initialize your account; Netscape will respond by creating some special files in your account and displaying the Owlnet "home page".
In a hypertext document, phrases highlighted by color and underlining are linked to other pages; click on them to see that reference (no matter where it is in the world). Try it! To return to the previous page, simply click on Netscape's most useful button: the Back arrow near the top left of the window.
The Netscape window has a scrollbar (when necessary) on the right side. It behaves differently that the xterm's scrollbar: click with the left button above or below the highlighted part to scroll up or down, respectively.
You can directly access an arbitrary Web document by clicking the Open button at the top of the window or by just typing into the "Location" edit box near the top of the Netscape window. Fortunately, you rarely have to specify an explicit location (or URL in WWW jargon) while net surfing. Access the Comp 210 home page at http://www.owlnet.rice.edu/~comp210.
Selecting the link labeled "Labs", followed by the link "Lab 1" will give you this handout. Surf some of the other links. After lab, you should look through the Comp 210 home pages, which contain office hours, homework, a link to the course newsgroup, lecture notes for last year, and more.
If you find a document of particular interest, you can remember it by creating a bookmark for it: pull down your Bookmarks menu, and select Add Bookmark. Any time you want to revisit that page in the future, you can just select it from the Bookmark menu (where it is now listed).
To see what else the web is good for, here are a few samples:
(Once you are familiar with a Unix editor, you may want to create your own home page. To see what a web page really looks like, select Document Source under the View menu of Netscape.)
To exit Netscape, select Exit from the File menu.
Newsgroups are electronic bulletin boards where everybody can post and read articles on certain topics. There is a newsgroup specifically for this course, rice.owlnews.comp210. You should read the newsgroup every day or two, as helpful hints and clarifications are posted there regularly. Also, if you have a question relating to the course, post it to the newsgroup. Similarly if you have an answer for somebody else's question!
In newsgroups, the idea is that once you've read a message, you probably don't ever want to see it again (unless you do something special). So your newsreader "marks" an article as read, and next time you read news it only presents you with unmarked articles.
There are many different new-reading programs you can choose from. Two leading contenders are Netscape and Pine, each of which makes reading news analagous to their way of reading mail.
From the comp210 web page, follow the link "The Newsgroup". This opens a separate Netscape window, with three panes: the list of newsgroups (upper left), the list of articles in current newsgroup (upper right), and the current article itself (lower).
Click on an article's heading to read it, or use the Next button to go to the next unread article. You can toggle the already-read status of an individual article by clicking on the green dot next to the subject.
You can mark all the articles in the newsgroup as read by clicking on the Group button that has a picture with a bunch of checkmarks. More commonly, you will want to mark all the articles in a "thread" of conversation as read by clicking on the Thread button.
An unmarked (unread) article is shown in bold face, and has a diamond between the Sender and Subject, while a marked (read) article is in normal-font, with a dot instead of a diamond. As you read articles, you see them change from unmarked to marked.
How to do something special, to be able to read articles again later: you must change an article from marked back to unmarked.
Articles also expire after a while. For instance, you don't see articles posted three years ago, simply because the news server (the local Rice computer that gets/posts news from other computers on the net) doesn't store articles forever. How old an article has to be before it expires varies: Rice course-newsgroups tend to stay around several semesters, while articles in alt.sandwiches.pouting expire after about a week.
In the list of all newsgroups, click on a newsgroup's name to read it. Subscribed newsgroups are shown with a check to the right of their name, and unsubscribed newsgroups just have a dot; click on that symbol to toggle that particular newsgroup's subscription status.
Note that initially, only subscribed newsgroups are shown (and the course newsgroup, since you selected that one in particular to start the newsreader). Under the Options menu, you can modify this by selecting either "Show all newsgroups" or "Show subscribed newsgroups".
Some newsgroup categories (like alt, rice, etc.) have a triangle to the left of their names. When this triangle is pointing down, the view is expanded to show all newsgroups within that category; click on the triangle to toggle whether it points down or not.
To post your own message to a newsgroup, make sure the newsgroup is selected, and click the To:News button in the upper left corner. You'll be put inside an editor to compose the message. When you are done, either click the Send button to post the message, or you select Close from the File menu.
Note that under the File menu of Netscape's News window, Close just closes the News window only, while Exit actually means exiting all Netscape windows.
Start DrScheme by either
First, from the Language menu, select Configure Language. From the menu that gives you, select Beginner. DrScheme then says to restart the program, i.e., exit DrScheme and then start it again. DrScheme has the notion of "language levels", and the Beginner level should be the most helpful for you currently. It will give you an error for programs that are valid Scheme, but use features that we haven't taught and are assumed to be typos. I.e., it should help you find more of your mistakes.
The DrScheme window is divided into two halves. The lower half, or interaction window, is essentially a Scheme calculator. The top half, or definition window is where we enter all of our (define ...) expressions.
Try entering some small Scheme expressions in the interaction window. DrScheme will respond with each expression's value:
This is also an example that you can simply type in an identifier to see if it's used. E.g., what's the name of a function for negating a boolean? You haven't seen it yet, so try entering negate as your guess. Well, that gives an error, so try entering not. Well, that is defined, so let's see if it's the right thing: try entering (not #t). Yep, it responded #f. It looks like it's probably the right thing.
To evaluate expressions like (* 3 x), we need to make definitions in the definition window. But when we do, we need to load those definitions into the interaction window.
Note again that DrScheme visually matches parentheses to help you make sure that you typed everything correctly. As an additional check, select the Check Syntax button. This checks the entire definition window for syntax errors, and annotates your code, e.g., highlighting identifiers with color.
To use your definition, select the Execute button. This essentially starts DrScheme afresh, knowing only the definitions currently in the definition window. Now enter (* 3 x) in the interaction window -- it responds with 15.
Let's try some additional definitions.
Note again the parenthesis matching. Also, move the cursor onto each of the opening and closing parentheses and note how DrScheme highlights the appropriate section of code.
Load the definition by selecting the Execute button. Enter (square 5) (in the interaction window) -- it responds with 25, of course.
In order to read your definitions more easily, it's generally helpful to put some English comments before each definition. In Scheme, a comment begins with a semicolon and ends with the end of that line, e.g.,
; returns the square of a number (define square (lambda (n) (* n n)))Comments are ignored by the computer -- they are only to help the human reader of the program (which could be you, the programmer, as it can be easy to forget what a program is supposed to do). Even better for this example, because it's more precise is
; square: number -> number ; returns the square of a number (define square (lambda (n) (* n n)))Where the first comment line states that the function square takes a number as input and returns a number as output.
It is also important to test your code. Let's test our simple definition of square. In the interaction window, we can try
(square 5)and it responds with the answer 25. This is a really simple program, but we could still try a couple more examples. With more complicated programs, testing becomes very important.
On most assignments, you will need to turn in your tests, as well as your code. For convenience, we will put these tests together with the code, but in comments. For example, cut (this command is in DrScheme's Edit menu) from the interaction window our test of
> (square 5) 25and paste (again in the Edit menu) this below the definition of square, and comment out the test:
; square: number -> number ; returns the square of a number (define square (lambda (n) (* n n))) ;> (square 5) ;25Keeping the > prompt in there helps distinguish what was the test expression, and what was its result.