WXME0104 ## wxtextwxtabwxmediawximage$(lib "comment-snip.ss" "framework")+(lib "collapsed-snipclass.ss" "framework")drscheme:sexp-snipdrscheme:number,(lib "number-snip.ss" "drscheme" "private")"drscheme:vertical-separator-snip%wxbaddrscheme:xml-snip(lib "xml-snipclass.ss" "xml")drscheme:scheme-snip"(lib "scheme-snipclass.ss" "xml")wxloc#K ZZZZ€ÿ€ÿ€ÿ StandardK Courier New ZZZZ€ÿ€ÿ€ÿF?ð\ZZZ?ð?ð?ð"€‹"Matching Parenthesis StyleF?ð\ZZZ?ð?ð?ð"€‹"F?ð\ZZZ?ð?ð?ð(drscheme:check-syntax:keywordF?ð\ZZZ?ð?ð?ð(F?ðZZZZ?ð?ð?ð€ø@'drscheme:check-syntax:unbound-variableF?ðZZZZ?ð?ð?ð€ø@F?ðZZZZ?ð?ð?ð$$€Œ%drscheme:check-syntax:bound-variableF?ðZZZZ?ð?ð?ð$$€Œ drscheme:check-syntax:primitiveF?ðZZZZ?ð?ð?ð$$€ŒF?ðZZZZ?ð?ð?ð3€‡'drscheme:check-syntax:constantF?ðZZZZ?ð?ð?ð3€‡'F?ðZZZZ?ð?ð?ð€„<$drscheme:check-syntax:baseF?ðZZZZ?ð?ð?ð€„<$F?ðZZZZ?ð?ð?ð?ð?ð?ðXMLF?ðZZZZ?ð?ð?ð?ð?ð?ðK ZZZZ€ÿ€ÿ€ÿK Courier New ZZZZ€ÿ€ÿ€ÿF?ð\ZZZ?ð?ð?ð"€‹"F?ð\ZZZ?ð?ð?ð(F?ðZZZZ?ð?ð?ð€ø@F?ðZZZZ?ð?ð?ð$$€ŒF?ðZZZZ?ð?ð?ð3€‡'F?ðZZZZ?ð?ð?ð€„<$F?ðZZZZ?ð?ð?ð?ð?ð?ðG?ðZZZZ?ð?ð?ð?ð?ð?ðF?ðZZZZ?ð?ð?ðPP€øG?ðZZZZ?ð?ð?ðPP€øG?ðZZZZ?ð?ð?ðdG?ðZZZZ?ð?ð?ð?ð?ð?ðF?ðZZZZ?ð?ð?ðPP€øG?ðZZZZ?ð?ð?ðPP€øG?ðZZZZ?ð?ð?ðd€­ (define speed-limit 75) (define scofflaw-margin 1.1) :(define my-cruising-speed (* speed-limit scofflaw-margin)) my-cruising-speed = 82.5  ;(set! speed-limit 55) ; ;speed-limit = 55 ;my-cruising-speed = '???    9(error 'hello-class "Stay tuned for further examples...") ;;;;;;;;;;;;;;;;;;;;;  (define a (+ 2 3))  (define b a) (set! a 'volkswagen) b  (define aa (make-posn 2 3)) (define bb aa) (set-posn-x! aa 99) bb   Ê Similarly, if you call =translate-posn! (a function which changes the posn passed in) and pass in bb, #both aa and bb can notice a change. But: 

(define (silly x)
W  (begin (set! x 17)    ;legal in "PLT/Pretty Big" but not in "Advanced" language level
         x))

a
	(silly a)
a

aa

(silly aa)
aa
bb

9(error 'hello-class "Stay tuned for further examples...")

;;;;;;;;;;;;;

(define seed 0)
(;; return a pseudo-random int in [0,100)
(define (rand)
$  (begin (set! seed (next-num seed))
         seed))

!;; next-num: number --> number
7;; Return the next number in an (ahem) random sequence.
;;
(define (next-num n)
"  (remainder (+ 17 (* n 41)) 100))


9(error 'hello-class "Stay tuned for further examples...")
;;;;;;;;;;;;;;;;;;;;;

(define directory empty)

#(define-struct entry (name number))

0;; add-entry!: symbol number --> list-of-entries
-;; SIDE-EFFECT: add a new entry to direcotry.
%;; We return (the updated) directory.
5;;   (Not necessary to return this, since anybody can
5;;   look up the placeholder "directory" at any time,
;;   to get that same info.)
;;
=;;   However, a useful rule of thumb: when writing a function
:;;   which modifies an object but doesn't otherwise return
D;;   an interesting value, have it return the object being modified.
:;;   This is often convenient in allowing you to pass that
;;;   value to the next function, w/o having to use "begin".
;;
 (define (add-entry! name number)
  (begin
>    (set! directory (cons (make-entry name number) directory))
    directory))

$;; lookup: symbol --> entry or false
;;
(define (lookup name)
!  (lookup-helper name directory))

<;; lookup-helper: symbol, list-of-entries --> entry or false
;;
$(define (lookup-helper name entries)
   (cond [(empty? entries) false]
J        [(cons?  entries) (if (symbol=? (entry-name (first entries)) name)
-                              (first entries)
E                              (lookup-helper name (rest entries)))]))