Thursday, March 7, 2013

Weekly log 6 post reading week


This week we learned:
We learned a coding/decoding method called ROT 13 and we actually created a function on Dr.Racket to mess with. The idea is easy to comprehend to humans, however, like the peanut butter sandwich recipe, we need to be very specific and consider each situations, like considering the case that our input is not a letter, for instance, “?” or “=”. In this case, we need to use a function called “cond”
(cond
[question1 answer1]
[question2 answer2]
...
[else defaultAnswer])

If question1 evaluates to true, answer1 is produced. Otherwise we move on to the next question/answer pair. If none of the others match, we get else/defaultAnswer.

Thank to Danny’s explanation, not it is really clear.

If we input an “?”, we should get a “?” back.

My questions about assignment 1:
The ecosystem one:



; update-ecosystem : ecosystem -> ecosystem

; Produce a new ecosystem accounting for new

; mouse and fox births and deaths.

(define (update-ecosystem eco)

(make-ecosystem

; max makes sure mouse population doesn't drop below 1

(max 1

; !!! fix the expression the comment below describes.

; subtract number of mice that get eaten annually from the number

; of mice in eco, plus the new births

(- (+ MICE-START (new-mice MICE-START )) ;mice in eco plus the new births

(eaten-mice (+ MICE-START (new-mice MICE-START )) ;eaten mice (mice) (foxes)

(+ FOXES-START (new-foxes (+ MICE-START (new-mice MICE-START )) FOXES-START)))))



; max makes sure fox population doesn't drop below 1

(max 1

; !!! fix the expression the comment below describes.

; subtract number of foxes that die annually from the number

; of foxes in eco, plus the new births

(- (+ FOXES-START (new-foxes (+ MICE-START (new-mice MICE-START )) FOXES-START) 
foxes in eco plus new births

(dead-foxes (+ FOXES-START (new-foxes (+ MICE-START (new-mice MICE-START )) FOXES-START)) ))))))
dead-foxes nf nm

However when I run it, the mice eat all of the foxes immediately! 
What did I do wrong? 

No comments:

Post a Comment