2014年11月25日星期二

Week 11 Nov 17

Lists of Lists of Lists of 


Firstly, we should know what recursion means "A common method of simplification is to divide a problem into subproblems of the same type. As a computer programming technique, this is called divide and conquerand is key to the design of many important algorithms. Divide and conquer serves as a top-down approach to problem solving, where problems are solved by solving smaller and smaller instances. A contrary approach is dynamic programming. This approach serves as a bottom-up approach, where problems are solved by solving larger and larger instances, until the desired size is reached".(http://en.wikipedia.org/wiki/Recursion#Recursion_in_computer_science)

In last few weeks, we already learn the recursion tree, 
today I learn the recursion number lists
From notes there is an example:

>depth (list (list (list 1
                         2)
                   3)
             (list 4)))
>3

The answer is 3 that because:

*(list 1 2) and (list 4) is one 

(list(list 1 2) 3 (list 4 ))is two

(list (list (list 1 2) 3 (list 4 ))) is three

* importantly: lists of lists of lists… are a inclusion relation and not a coordinating relation

Also, we have other method to get the answer 3 that is:
(define (depth lol)
  (cond [(list? lol) (+ 1
                        (apply max
                               (map depth lol)))]
        [else 0]))

By the way, we have a second project in this week and due in early december.
I will know the second term test marks in Friday and I think I will not get a high mark TT



week 2 suptember 16

Lets introduce some basic knowledges :
  • Flip-horizontal: a picture change from left to right 
  • Flip-vertical: a picture change from top to bottom 
  • above: this is hard to describe so I give you a example : 
>(Above  ♠  )
  
  
 
  • beside:   
>(beside  ♠  )
   
  • add:
>(+ 10 2)
  12
  • minus:
>(- 10 2)
  8
  • times:
>(* 1 2 3 4)
  24



Sorry I'm late to write earliest blog ^^



2014年11月17日星期一

Week 10 Nov 10

Last week we have a term test 2 so I prepare for this term test.

Decimal notation and Binary represention :

Decimal notation- It's a math system about 10

I find decimal notation's history on Wikipedia:

Eg: Lbn Laban addition
6425
839

Eg: Sun Zi division

Binary represention-

I recall the term test 2 question and there is a calculation method:
Add: 
00+00=00
00+01=01
01+00=01
01+01=10

When we meet 01+01 we need to carry a 1.

Such as:

To summary, there are the decimal and the binary but there still has an interesting rule that are 
from decimal to binary and from binary to decimal.


Eg: 

Eg: 


All the picture are from internet 






2014年11月9日星期日

Nov 3 week 9

In the first term test, there is a kind of built-in values:
Number-Boolean 
Image-image

Now I know that called The DATA-TYPES

  • Number
  • Image
  • Boolean
  • String
  • List
  • Color
I guess it Will appear in the second term test too!!!


Here is an example,

There are two people 

Lucy LuLu 1990
George Brown 1991

(define Lucy ( list "Lucy LuLu" 1990))
(define George (list "George Brown" 1991))

(Define person-name first)
(define person-birth-year second)

Lucy
"Lucy LuLu" 1990





Define-strict
I find a picture that about check-expect


2014年11月4日星期二

Week-October 27

Last week we learn how to make some beautiful colours for a picture.

Firstly,
The range among red green and blue are (range 0 256 1)


such as:

So… Here is a question, why?
Prof. give us a website and that says:"Additive color is color created by mixing light of two or more different colors. Redgreen, and blue are the additive primary colors normally used in additive color system. "(https://en.wikipedia.org/wiki/Additive_color)

Example 1:
(square 50 "solid" (make-color 255 255 0))
We can get a yellow square
There are all the possibilities


I think these just a warm up for colour - -
By the way, I do not know how to write last week quiz, I feel so sad.
I will learn PDF 1 2 as soon as possible.


2014年10月27日星期一

Week - OCTOBER 20

Last week we learn Sierpinski triangle - an interesting triangle model!                                                  

There is an example:

(require picturing-programs)
(triangle 25 "solid" "red")


(define (stack an-image)
          (above an-image (beside an-image an-image)))

(define (Sierpinski n)
     (cond [ ( zero? n ) 🔺]
               [else (stack ( Sierpinski (- n 1)))]))
-------------------------------------------
(stack (Sierpinski (- 1 1)))

•it will appears a big triangle with four small equally triangle.
That because (Sierpinski 0) is a single triangle, (stack 0) means repeated addition other three triangles (a big triangle with four small equally triangle)

2014年10月17日星期五

Friday, October 17 2014

last week, I review the first term test and conclude five  definitions from lectures.

1) Euclidean Algorithm         VS         Brute Force

Brute Force  needs more steps to get the result but Euclidean Algorithm has less steps. It is simply to get results.

2)Adds up           VS         Algebraic formula

Algebraic formula has less steps than Adds up method

3)The Collatz  sequence

Assume a number 10,
it is even so divide 2 get 5
it is odd so times 3 plus 1 get 16
it is even so get 8
it is even so get 4
...2
...1
 the final answer is 1,

but it is only a suspect.

4) Binary Search       VS         Brute Ford


Binary Search is the best choice because Brute Ford has many steps,Binary Search has less steps



3
5)Expentional growth
6)Fibonacci Sequence