Assignment #0 is due at 11:59 PM on Friday, 3 October 2003. Submit your work according to the general instructions.
This assignment is designed to exercise you in the annoying logistical details that you need to handle while programming. There is no interesting programming problem for you to solve. It is very important that you are not distracted by too many logistical details in the subsequent assignments, which will present you with interesting conceptual problems to solve. So, try to shake out your methods for working on this trivial assignment.
I've described much of what you need to do for Assignment #0 in highly annoying detail. I will never do that again in this class. After this assignment, I will describe your work clearly enough that you can figure out what you need to do, possibly after asking some questions. In order to succeed in the later work of the course, you must use Assignment #0 to become fluent in the basic operations of programming and exploring with DrScheme. If you fumble around a lot about which buttons to push when, you will not be able to concentrate on the interesting problem-solving content of the real assignments.
You only hand in a small part of the work in this assignment. But do it all.
These instructions describe how to perform assignment #0 on one of the CS Department's GNU/Linux computers. You may use DrScheme on another computer if you like (e.g. the CS Department's Macintosh computers). In that case, it's a good idea to make sure that you have the same version of DrScheme (it was version 205 last time I checked). And you will have to figure out any differences in the methods of working. In particular, you will have to transfer your files to the CS Department's Linux/Unix file system in order to hand them in. I will not have time to figure out problems due to the use of different computers.
mkdir
" command to create a directory in which to work on
CMSC 16100 homework, with a subdirectory named "Asst0
"
for this assignment. Use the "cd
" command to move into
that directory, and the "ls
" command to notice that
there's nothing in it yet. If you don't know how to do all this stuff
in Linux, get help from a friend, a TA, or a consultant in
the CS instructional computing labs in Regenstein.drscheme &
" to
your interactive terminal/shell window (the "&
" causes
DrScheme to run in the background, allowing you to type
further commands if you need to).(+ 2 3)
" in the interactions window, and hit the
enter key to evaluate that expression. You should see the result
"5
", but also a yellow-highlighted warning:
"WARNING: Interactions window is out of sync with the
definitions window. Click Execute.
" In this case, it really
means that the interactions window has not incorporated the change
from Beginning Student to Beginning Student with List
Abbreviations.Escape p
" to recover your expression, and
"Enter
" to evaluate and display the result
"5
" without the warning.(+ 2 3)
", such
as(+2 3)
(2 + 3)
((+ 2 3))
( + 2 3 )
(* (+ 2 3) (/ 42 7))
(*(+ 2 3)(/ 42 7))
Escape p
" to recover old
expressions and then editing them.(append (list "a" true 3) (list false "efg" 'hi))
(length (append (list "a" true 3) (list false "efg" 'hi)))
(list)
(append (list 1 2 3 4) empty)
(append empty (list 1 2 3 4))
(length (list (list 1 2 3 4) empty (list 5)))
(list? (list 1 2 3))
",
"(list? empty)
", and "(list? "(1 2 3)")
" to
get an idea what lists are (and what they are not).number?
", "boolean?
",
"symbol?
", "string?
", and
"char?
". Figure out the types of lots of values such as
"123
", "'123
", "(list "1" "2"
"3")
", "abc
", "'abc
", "(list
"a" "b" "c")
". Most of these make a lot of logical sense after
you assimilate them, but there are some subtle quirks, such as the
different effects of single- or double-quoting "123
"
vs. "abc
". It's not important to understand the whole
mess right now---just get a sense of the scope of the problem, and
we'll treat each type more carefully later.This is a tiny Scheme program, defining the function; rotate-list-left is a function that rotates the elements ; of a list to the left, moving the first element to the ; last position. (define (rotate-list-left listin) (reverse (cons (first listin) (reverse (rest listin)))))
rotate-list-left
. Select the "Check Syntax" button. If
you typed it all in correctly, you will see a nicely color-coded
display of the text. I don't recommend learning the meanings of the
colors (I still haven't done so), but I think their presence makes the
program easier to read.listin
", perhaps as
"litsin
". Each time you change the program, select "Check
Syntax" again.listin
and
notice the blue arrows. Think about what they might be telling
you. This is some of the really nice stuff in DrScheme, and
there's a bit more of it to discover.(rotate-list-left (list 1 2 3
4))
in the interaction window. Oops! We forgot to
select the "Execute" button. DrScheme warns us that the two
windows are out of sync, and tells us that
"rotate-list-left
" is an "undefined identifier". Select
the "Execute" button. The nice coloring disappears, which annoys me a
lot, so I select "Check Syntax" again immediately. Your expression to
evaluate also disappears from the interaction window, but you can get
it back with "Escape p
". When you finally see it, the
result of this example should give you the basic idea of what
rotate-list-left
is intended to do.rotate-list-left
, and evaluate other expressions to
illuminate those subtle points. If you must do something on your own
already, figure out how to define rotate-list-right
in
the same style. It's only slightly more complicated;
") to the top of
the definitions window with your name displayed prominently, as
specified in the
general instructions./rotate-list-left.scm
" to the end of
that stuff, and select the "OK" button. Back in your Linux
terminal/shell window, type "ls
", and notice the new file
named "rotate-list-left.scm
". That file contains only the
contents of the definitions window. Get in the habit of selecting
"Save" after every change to the definitions. You only have to enter a
file name the first time.(rotate-list-left (list 1))
", and in the "Expected"
window enter "(list 1)
". Select the "Execute" button on
the test suite window (not the one on the definitions
window). "(list 1)
" will appear in the "Actual" region,
and a big green check mark to indicate that the program passed the
test.(rotate-list-left (list 1 2))
and
(list 2 1)
(rotate-list-left (list 1 2 3 ))
and
(list 2 3 1)
(rotate-list-left (list (list 1 2 3)))
and
(list (list 1 2 3))
(rotate-list-left (list (list 1 2 3) (list 4 5 6) (list 7 8 9)))
and (list (list 4 5 6) (list 7 8 9) (list 1 2 3))
(rotate-list-left empty)
and
empty
empty
is arguably the right result, and why my program
doesn't get it.(rotate-list-left empty)
above), no further test cases are executed. That's why I saved the
empty
test for last. There is also no way to incorporate
tests that are intended to fail in this way, even though that
is sometimes the desired result. Later on, we may switch to a more
carefully crafted testing procedure that doesn't look as nice.rotate-list-left.tst.scm
".Hand in your definitions and test suite according to the general instructions. In this assignment, you just type
To avoid typing the path prefix "~odonnell/Teaching/Utilities/handin 0 rotate-list-left.scm rotate-list-left.tst.scm
~odonnell/Teaching/Utilities/
", see the
section on PATH
in the
general instructions.
This is a good time to read about
the handin
command.
![]() | |