In this lab, you will familiarize yourself with the basics of DrRacket, simple UNIX commands, and the SVN assignment submission system.
Note: Once your account is created or if you have not been notified about joining the discussion board, call me over so I can write down your name and email address and send you a request to join the course discussion board.
Type in the following command into the Terminal:
svn co https://phoenixforge.cs.uchicago.edu/svn/yourusername-cs105-win-15replacing yourusername by your CNet username in lowercase. You will be prompted for your CNet password. If you get a prompt asking you if you would like to accept the certificate, press p (meaning to accept permanently).
(For example, since my username is hmmorgan, I would type svn co https://phoenixforge.cs.uchicago.edu/svn/hmmorgan-cs105-win-15.)
If you registered late or not at all, this step may not work for you. Please raise your hand if you are having trouble. You will need to submit your work through e-mail rather than SVN.
What we just did is check out the current version of your personal repository for this class. The repository is stored on a central university server, and is accessible only by you and the course staff. You will use it to save and submit your homeworks and labs.
If all goes well, the Terminal will respond with Checked out revision 0.
cd yourusername-cs105-win-15The first command takes you into your project directory, which is yourusername-cs105-win-15 and the second command lists the directory's contents. (In UNIX-speak, cd is short for "change directory" and ls stands for "list contents".)
ls
If you are on the right track, the Terminal will tell you that there is nothing in the folder by showing you nothing on the terminal.
mkdir lab1
You should now see the lab1 folder that you just created listed on the terminal.
ls
Type in the following command
svn add lab1and the terminal will respond by showing you,
Now you have told svn to add the lab1 folder to your repository.A lab1
Note: Anytime you create a new file, folder, or want to add a file to your repository for the first time you will need to use svn add . You only need to do svn add once.
This creates a blank .rkt (a Dr racket file) in your yourusername-cs105-win-15/lab1 directory.
Click on the View->Show Interactions menubar item. This splits the DrRacket screen into the two panels.
We will define our programs in the upper panel (i.e. definitions window) and evaluate Racket expressions in the lower panel (i.e. interactions window).
Before we begin, we must select a "language". From the Language->Choose Language... menu item, choose Beginning Student under the How to Design Programs section, and click OK. Click the Run button and the selected language will show up in the status bar at the bottom of the interactions window.
Move the cursor to the lower interactions panel and at the command prompt >, type the following:
"hi"Note how the read-evaluate-print (REPL) loop produces a response: "hi". DrRacket reads in this string literal we typed in and evaluates it to itself.
Now type in
'hi
What happens if you type this in?
hiThe reason is that "hi" and 'hi are strings, whereas the plain hi is a variable. In this case, we have tried evaluating a variable without defining its values first.
5What is the response? Make sure you understand what happened in the REPL loop.
(+ 1 2)This time, DrRacket evalues this expression to the value 3. Try evaluating
(+ 1 2 3)Note that the form of this numerical expression is (operator operand1 operand2 ...). +,-,/,* are primitive arithmetic operators.
Each operand can itself be a numerical expression. For example, here is another expression:
(+ (* 45 3) (- 4 2))Understand how this evaluates to the answer you get on the screen.
(+on separate lines.
(* 4 6)
(- 3 8)
)
Notice the indentation DrRacket provides, placing the two subexpression at the same indentation level to indicate they are both operands for the addition operator.
(/ 2)
(3 / 3)
(abs -2)abs is a primitive operator that computes the absolute value of a number. Now try
(abs -3 -4)Notice that the number of operands required in an expression depends on the operator. abs requires exactly one operand, whereas / requires at least two.
(You will notice that your earlier interactions from Part 1 disappeared from the interactions window. Don't worry about it -- we only need you to submit Parts 2 and 3.)
Write one comment above each of the expressions in your definitions window, briefly explaining what that expression does. Also write your name as a comment at the top of the window.
Now submit whatever you have so far through SVN. To do so, go back to the Terminal window from earlier. Type in
ls -l(l the letter, not 1 the number...)
This lists the contents of the directory in a detailed way, showing when the files were modified. You should be able to see that lab1.rkt was modifed by you just a few moments ago.
svn add lab1/lab1.rktNow you have added the lab1.rkt file (located in your lab1 folder) to your repository. Type in
svn commit -m "Commiting first part of lab1"This uploads your current work into the repository. The string after the -m flag is a message that explains your commit, and can be anything you like. Meaningful messages help you keep track of any additions and modifications to your code at each commit.
You should get a message saying
Adding lab1
Adding lab1/lab1.rkt
If you have any problems completing this part of the lab and committing your work, please raise your hand right away for help before proceeding to the next part.
Go back to your DrRacket window. We will now draw some pretty pictures. The image teachpack provides primitives for operating with images. Details on working with this teachpack are available at http://docs.racket-lang.org/teachpack/2htdpimage.html or through DrRacket's help desk. Please open this page and consult it as you go through the following exercises.
(require 2htdp/image)This loads the image teachpack.
(circle 10 'solid 'red)As you may have inferred, circle is a primitive operator that draws a circle with the specified radius, shading, and color.
(above (circle 10 'solid 'red) (circle 10 'solid 'red))It should be clear what this expression does. Check out the DrRacket documentation for the above operator if you have any confusion.
Please make sure your definitions window contains all the above expressions from part 3 as well as your comments, and that you have saved your work! You may use the interactions window for testing, but only content that is typed in the upper definitions window can be saved.
svn commit -m "Commiting part 2 of lab1"Once again, you should get a message that says Sending lab1/lab1.rkt. If you don't, please ask for help.
At this point, you are done with the lab, and you should commit whatever you have. If you have made a mistake and want to revise your work at any point before the deadline (end of your lab session), you can save your DrRacket file and commit again. That is the convenience offered by SVN! All your commits will be recorded, but we will only grade the final one, and anything after the deadline will be ignored.
Before leaving the lab, make sure you have committed (or if SVN is not set up for you, e-mailed) the latest version of your work, and log out of the machine. You can check that your work is saved by viewing your repository online. See "Submitting Your Work" below.
The DrRacket overlay operator overlays images on top of one another. Using this operator, draw a enclosed diamond that looks like this:
Hint: start by trying to overlay two rectangles of different widths and lengths and then use the rotate operatorand go from there.
Anytime you make changes to your repository (i.e. adding new or modified files/folders) you need to svn commit your changes. The command svn add did not save your lab1 folder or lab1.rkt to you repository. It only told svn that when you perform a svn commit that these need to be saved to your repository. Remember, as you go along make sure you svn commit your changes. You will be graded on what is in the lab1 directory at the end of your lab session. Convince yourself that your commit has been successful and that you have submitted the correct files and folder by following the instructions below.
How to Check your SVN Submission