Lab 1 is a self-guided set of exercises intended to increase your familiarity with the command line, subversion, and DrRacket. Even though you will commit a file to your subversion repository as part of this work, there is no official submission associated with Lab 1 and you will not be evaluated on it. You will be evaluated on all subsequent lab exercises.
Follow the steps below and ask questions as needed as you go along.
1. |
|
2. |
|
3. |
|
4. |
|
5. |
|
6. |
|
7. |
|
8. |
|
9. |
Start DrRacket. DrRacket may at some point ask you to choose a "language level." For this exercise, select the "Beginning Student" level. When we start using Typed Racket you will select the "Determine language from source" option. Type the following code into DrRacket's definitions pane: Click the "Run" button at the top of the DrRacket window, and make sure you understand what you see.9 (+ 9 1) (+ 1 9) (- 9 1) (- 1 9) Type the following code into DrRacket's definitions pane, under what you have already typed: Click "Run" again.(* 9 1) (* 1 9) (/ 9 1) (/ 1 9) Add these: Click "Run" again.(expt 9 1) (expt 9 2) (expt 1 9) (expt 2 9) (+ (expt 9 1) 1) (+ (expt 9 2) 2) (- (expt 9 2) (expt 9 1)) Now add these: Click the "Run" button again.(= (expt 9 1) (expt 9 2)) (< (expt 9 1) (expt 9 2)) (> (expt 9 1) (expt 9 2)) Finally, add these: "Run".;; a : Integer (define a 7) ;; b : Integer (define b 8) (* a b) (- (* b b) (* a a)) At this point, you should feel free to add, remove or modify any of the expressions of definitions in the definitions pane. Save your lab1.rkt file in whatever state it's in. When you do so, make sure to save it in the lab1 folder you created in the previous step. |
10. |
To push your lab1.rkt file into your subversion repository, you need to add it first, then commit it. Note that once you've added a file, you do not need to add it again, although you will (usually) commit it again many times. To do this, change into the root directory of your repository at the command line (you can use pwd to verify that you are in the correct directory). Then type these instructions: $ svn add lab1/lab1.rkt $ svn commit lab1 -m "committing lab1" |
11. |
You will now use Racket to render a crude illustration of a local landmark, the Sears Tower (which I refuse to call by its other name). At the top of your lab1.rkt file, type Somewhere below — it doesn't matter where, exactly — type(require 2htdp/image) After running, and hence registering this definition, you can view the illustration by typing(define sears-tower (above (beside (rectangle 2 11 "solid" "black") (rectangle 3 1 "solid" "white") (rectangle 2 11 "solid" "black")) (rectangle 10 30 "solid" "black") (rectangle 20 100 "solid" "black")))
Save the file. You don't need to add lab1.rkt to the repository again, because you've already done so. You do need to commit it again, though, and don't neglect the message (with -m "...") in your commit command. |
12. |
Getting out of trouble in the shell is a critical skill. Therefore, as the last exercise, we ask you to type some commands that will not succeed, to gain some experience with (minor) shell mishaps. Try to determine the result of each of the following commands before typing them: Explain (to yourself) the different results you observed typing the same command ls foo three times.$ cd ~ $ ls foo $ mkdir foo $ ls foo $ touch foo/FILE1.empty $ ls foo Now type this: Why does one rm command fail and the other succeed?$ rm FILE1.empty $ cd foo $ rm FILE1.empty $ ls foo $ cd .. $ ls foo Finally, try this sequence of instructions: $ touch foo/FILE1.empty $ ls foo $ rm FILE1.empty $ rm foo/FILE1.empty $ rmdir foo $ cd .. $ rmdir foo |
This concludes Lab 1. You do not need to remove any files from the computer at which you have been working. If you're working at a Linux terminal, your files will stick around; if you're working at a Mac, be forewarned the CSIL Macs are wiped clean every night. Committing your work to your subversion repository should always serve as a comfort to you, that your work is safe and sound. See you in class!