2013-03-15

CSC 104 Slog-Week Eight (Mar 4th – Mar 10th)

CSC 104 Slog-Week Eight (Mar 4th – Mar 10th)
Something new learned in the class:
[Computer system]
Major features:
Disc Drive
Monitor

CPU

-A Central Processing Unit (CPU)
--A control unit.
-Main memory
-Peripheral devices
--Keyboards
--Monitors
--Disc drives
--etc
  Arithmetic/Logical unit (ALU)
Basic arithmetic and logical operations that computer circuits can carry out on sequences of bits: addition, subtraction, multiplication, division, and the logical operations AND, OR, and NOT.
  Control unit:
Sequencing of operations (determining what happens when)
  The choice of instruction set
Whether to use a relatively small set of simple instructions (requiring each program to use a larger number of relatively fast instructions) or a larger set of more complex instructions (requiring fewer, but slower, instructions to implement a program).
  Program counter (PC): The register that the control unit uses to keep track of which instruction to carry out next. It is used to hold addresses (locations) in the main memory. Once the next instruction has been fetched and placed into the instruction register, it increments (increases) the PC to the location of the next instruction.
  The sort of instructions that are available can be grouped into three broad categories are:
-Arithmetic/logical operations.
-Data transfer (load or store in main memory)
-Program control (branch or halt).
  The process of adding two numbers stored in main memory and storing the sum in a third location
LOAD A1 R1
LOAD A2 R2
ADD R1 R2 R3
STORE R3 A3
HALT

[Dr.Racket]
   string-reverse : Produce string with characters in opposite order from s
 (define (string-reverse s)
  (cond
    [(zero? (string-length s)) s]
    [else (string-append (string-reverse (substring s 1)) (substring s 0 1))]))
(check-expect (string-reverse "string") "gnirts")
String Reverse

  palindrome? : To judge whether the s is a palindrome?
  (define (palindrome? s)
   (cond
     [(< (string-length s) 2) true]
     [else
      (and
       (palindrome? (substring s 1 (sub1 (string-length s))))
       (equal? (string-ref s 0) (string-ref s (sub1 (string-length s)))))]))
(check-expect (palindrome? "aa") true)
(check-expect (palindrome? "ab") false)
Palindrome

 Challenges I met this week
  
We met a really big problem when we were doing the project1 ecosystem. After w
e had done it, we clicked run and we found that the size of the image doesnt change and also, it said that function call: expected a function after the open parenthesis, but received 1000. Finally we changed
(ecosystem-mice eco (MICE-START FOXES-START))(+ (- MICE-START eaten-mice) new-mice))
 to
(+ (- MICE-START (eaten-mice (ecosystem-mice eco) (ecosystem-foxes eco))) (new-mice (ecosystem-mice eco))))
And it made the images change their sizes, seems that it works.

The test/quiz/assignment
The quiz this week is almost the same as last week’s test content. So hopefully I did a good job =D Although I still didn’t get the quiz paper till now lol.
This week I finished my project1 with my friend – another Emily. We started to do it on Wednesday and edited it over and over and over, since there were always some problems. Anyway it turned out to run really successfully at last. And hopefully we did everything right.

❤Feedback to other's slogs

I read 's blog this week. She wrote a lot about her problems of doing project1. Indeed, practicing is always harder than just saying. I left the comment:"Totally understood your feeling. Programming drives people to be crazy!" to her.

2 comments:

  1. Congratulations for finishing up the project and having done a good job! :)

    ReplyDelete