Lecture 2, June 21

The lecture notes I post serve two purposes: to remind you of the topics we discussed and to provide any interesting code examples I did during lecture. I would describe these notes as an outline, not a summary, of what I talked about during lecture. You are not expected to be able to learn the material simply from examining these notes, nor is reading these notes a reasonable substitute for attending lecture.

Command Line

Commands

Relative vs. Absolute Paths

You can specify a path two different ways. One is relative to the current working directory (the name you specify MUST be in the current working directory). The other is with an absolute path (you must specify the entire path from the root of the file system to the file or directory).

Subversion

Commands

Images

(require typed/2htdp/image)

Functions to create simple images: square, circle, rectangle, ellipse, line.

Functions to compose multiple images: beside, above, overlay, overlay/offset.

Other image functions: image-width, image-height.

Don't memorize any more than the above functions. Expect to rely heavily on the documentation for finding the functions you need for solving homework assignments.

big-bang example

This is a modification of the big-bang example in the text for typed racket.

#lang typed/racket

(require typed/2htdp/image)
(require typed/2htdp/universe)

(: number->square : (-> Nonnegative-Real Image))
(define (number->square s)
  (square s "solid" "red"))

(: decr : (-> Nonnegative-Integer Nonnegative-Integer))
(define (decr n)
  (if (> n 0) (sub1 n) 0))

(big-bang 100 : Nonnegative-Integer
          [to-draw number->square]
          [on-tick decr]
          [stop-when zero?])