The first class of this week, I learned how to define "sierpinski triangle" in the Dr.Racket. However, I could not see any difference between the use of "sierp_0" and the use of "(sierp 0)". We just replace "sierp_0" with "(sierp 0)" and keep other things the same to make a definition of "(sierp 0)".
To make the picture beautiful, we could replace "green" with "(make-color (random 256) (random 256) (random 256) 255)" to let the computer choose random colors for us.
The content of "sierpinki" won't be covered in test 2. In order to be well-prepared for test2, I did the sample test2. I was interested in the last question which is about palimdrone. I tried to figure out the definition of "palimdrone" and I made it. I thought the main idea was similar to the reverse-string which I learned in the last week. The first condition is that when the string-length of a string is less than 2, it must be a palimdrone because it is just one single character. If the string-length is greater than 2, then there will be a another condition: the first character of the string is equal to the last character of the string and the characters between the first and the last also form a "palimdrone". Then I copied the whole definition and wrote a check-expect for "palimdrone" in the Dr.Racket :
(check-expect (palindrome? "rot") false)
It passed the test! I felt so happy that I could do it on my own and succeed.
No comments:
Post a Comment