In order to use STk from Emacs, you should place the text
(load-file "~cslab/.emacs")in ~/.emacs, your Emacs init file. You can do this by typing:
echo '(load-file "~cslab/.emacs")' > ~/.emacs
If you don't use the tutorial quite yet you may be able to muddle along using:
To spell it out, go ESC x r u n - s c h RET. Your Emacs
should look like this:
If there are some error messages now, or when you load turtle.stk as described below, you are probably not loading the site-local initialization file we set up. If you have your own initialization file, then ours won't get loaded. You can either
rm ~/init.stkor add (load "~cslab/Tk-3.1.1/lib/stk/3.1.1/STk/init.stk") to your ~/init.stk.
(+ 1 2) RETURNand your screen should look like this:
Now type C-x 4 C-f foo.stk RET to make a new file, and insert the text
(+ 1 (+ 2 (+ 3 (+ 4 (+ 5 (+ 6 (+ 7 (+ 8 (+ 9 10)))))))))into it. Save the file with C-x C-s. Your emacs should now look like
For now, we're going to use ``turtle graphics,'' a cute way of doing graphics invented by Seymore Papert at the MIT AI lab. To get the turtle graphics package into stk you have a load the turtle package, via
(load "~cslab/CS257/turtle.stk")to the stk prompt, or C-c C-l ~cslab/CS257/turtle.stk
Now you have access to some new procedures. You can figure out what they do from their names and by playing around.
(home) (clear) (down) (up) (move distance) (moveto x y) (turn degrees) (turnto degree) (east) (west) (north) (south) (colour num) ; default is 0; num between 0 and 15; ; different stipple patterns (width num) ; default is 0; 10 is about an inch wide (write "text") (screen-dump "filename.ps")
If you can't stand the British spelling, do this:
(define color colour)
;;; Triple semicolons are used for ;;; block comments on the left margin, ;;; for instance in file headers and ;;; before a definition to explain what ;;; the thing about to be defined will ;;; do. (define (fact n) ;; Double semicolons are used for comments ;; that should be indented the same amount ;; as the following line of code. (if (= n 0) 1 ; single semicolons are on the right (* n (fact (- n 1))))) ; like this.Emacs knows this convention. M-; move to the comment on the current line, creating one if necessary.
Get this stuff figured out now and it won't get in your way later. Emacs is the best editor ever for writing computer programs, in almost any language. Work through its tutorial, later in your career you won't be sorry.
And be sure to turn in your problem set via e-mail to firstname.lastname@example.org before it's due (5pm Tues Sep 2).
An ideal problem set handin can be fun to look at.