Sunday, February 17, 2013

Weekly Log5

What I learned this week:
1. Digital and Binary Concept
  Computers are based on two ideas, digital and binary. Digital means the discrete states in stead of smoothly-moving states. Binary is the smallest and most easily designed states. It is a number system with a base 2 instead of 10 in our most frequently used number system.
2.Boolean System
Professor explained Boolean logic by using electric circuit.
(and a b): the output is true if and only if both a and b are true.It is false if either a or b is false.
(or a b): the output is true if either a or b is true. It is false if and only if both a and b are false.
(not true) is false.
(not false) is true.
3.binary operation
  0 + 0 =0
  0 + 1 =1
  1 + 0 =1
  1 + 1 =0 (carry 1 to the next digit)
 how to convert binary number to number:
for example: 110 = 0 *1 + 1*2 + 1*4 =6

My questions on DrRackt:


key-press : image string -> image
; Produce the current image for any key except
; down arrow, but STOP for down-arrow
(define (key-press im k)
  (cond
    [(equal? k "down") (stop-with STOP)]
    [else im]))   ------> here I don't understand "cond" and "equal?" What is the "k" for?)
(check-expect (key-press BAR "hello!") BAR) ---> What does this mean? what is the "hello!" for?)
(check-expect (key-press SH "down") (stop-with STOP))



Questions on the lecture:
How to write numbers in binary?

1 comment:

  1. Here's how (cond ..) works. It has the following pattern:

    (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.

    The placeholder k stands for a string representing the key that was pressed. If the key is the down-arrow this string is "down" and the answer (stop-with STOP) is produced.

    The check-expect tests what happens if the model is the image BAR and some keystroke is represented by the string "hello!". Since the keystroke doesn't produce "down" we get the answer for else --- the image that placeholder im represents.

    These are great questions, and your TA can probably help you with them.

    ReplyDelete