Thursday, 21 March 2013

csc week #8

for the lecture this week we have learned about how Von Neumann looks like, its basically bus connects ALU/control to memory (RAM) and I/O keyboard, monitor, storage. and how computer store information ( hard-drive, flash memory, CD etc)

and for week 8 to 10 we were working on the same topic-recursion.

for example : g : number -> image
(define (g d)
(cond
[(> d 0)
(overlay
(beside (g (- d 1)) (g (- d 1)))
(square (* 2 (image-width (g (- d 1)))) "outline" "green"))]
[else (square 10 "outline" "green")]))

the above command is trying to produce an image with condition "d (a solid number) bigger than 0"

if you put 0 instead of d, than it will produce " square 10 "outline" "green" " because for everything

less or equal to 0, that's under the condition [else (square 10 "outline" "green")]

if you put 1 instead of d it will gives you:

1) 2 (square  10 "outline" "green") besides each other

2) a bigger size of a square : (square (* 2 (image-width (g (0)))) "outline" "green")

3) and they overlay each other.

it looks complicated to me at first, but if you split up everything try to read it line by line, figure out

what each line is doing what, then everything becomes easy.

We have done lots of similar problems for the past 2 weeks (week 9 and 10) I am pretty confidence

for how to handle this type of problem.


1 comment: