2012年10月27日星期六

Week 7

 For this week's lecture, we study what von neumann looks like, input, output, shorage and the protection from machine.
    We study some simple orders in Dr.Racket.
For example, if we put this oder in Dr.Racket:
; number-hunch : number -> string
; Is n really, really big?
; that is, is it more than 101
(define (number-hunch n)
  (cond
    [(> n 101) "Oh, it's *really* big"]
    [else "Not so big"]))
(number-hunch 5)
(number-hunch 102)
(define (GCD m n)
  (cond
    [(zero? n) m]
    [else (GCD n (remainder m n))]))
(GCD 35 15)
(GCD 15 35)
To run this one, we can get " Not so big" if numer-biunch is 5. The result of both (GCD 35 15) and (GCD 15 35) are 5.

没有评论:

发表评论