TOPIC of the Week: Algorithms, Dr. Racket Language, Expressing, Combining and Transforming Values using Dr. Racket Language
Introduction:
Hello, and welcome to SLOGging for Survival! :) I'm glad you dropped by! In this Blog, I will be keeping a log of my participation in a course I am taking for Computer Science; recording milestones, difficulties, and steps to solve these difficulties as I learn. Also, I'll be reacting to concepts presented in the course material that I find interesting, weird, OR wacky! I will finally be adding questions whenever I think of one that I will be answering when I gain more knowledge about the subject, so, don't be alarmed! ;) hope you enjoy your visit! :D
*Side note*: While composing this particular post, and because I now am somewhat familiar with what programming codes look like, I noticed that when one clicks the "HTML" button on the upper left side, the program code appears for what I have written thus far. Awesome and interesting! :)
Question to be answered later on (hopefully):
What programming language is being used to code for text (i.e. Dr. Racket, Java, etc.)??
(Reminder: I will be able to answer this question in another post, hopefully!)
Getting into the "SLOG" of Things:
In class this week (Week #2), we discussed whether or not we could use algorithms to solve big problems (such as the meaning of life, or why life on Earth still continues to survive). The Instructor skillfully showed the class the potential issues with such an algorithm, such as if more than one way is created to solve issue 'X', then which way is best? As well, we considered how long and tedious it would be to write this algorithm. Then, tips were given to solve new algorithmic problems, which I found extremely helpful because it will be of great assistance in the rest of the course!
I really enjoyed learning about algorithms because they genuinely interest me, and I LOVE finding more efficient ways to do my Philosophy homework! ;)
Also, we explored applications of Dr. Racket, and learned about racket values, but, more specifically: 1) Expressing Values, 2) Transforming Images, 3) Combining Values and 4) Decomposing Values.
A short description and explanation of what we learned in each section of racket values:
1) Expressing Values:
- Flipping images (written as: flip-horizontal (p), or flip-vertical (p)). (p) is the image copied.
- Converting decimals to improper fractions (done by right- clicking the decimal and selecting: "convert to mixed fraction")
- Finding dimensional values (height and width) of 2-Dimensional objects (written as image-height (p), or image-width (p)).
- Finding the number of characters in a word/ sentence (performed by writing the word/ sentence wanting to be interpreted in (""). I.e. "amazing" has 7 characters. But, to find the number of characters in "amazing", I would type (string-length "amazing") into the interactions pane of Dr. Racket (not the top pane because that's where functions are defined). 7 would be the result of typing this word and using the latter as an algorithm.
- Using true and false functions: i.e. (and true false) --> false (the "and" means ": are both of the words true?), i.e. 2. (or false true)--> true (the "or" means: at least 1 of these words are true).
Something I enjoyed about this section was flipping images because I found it fun to change the original image to something different, and because this was a lot easier than trying to find a way to flip the image! I LOVE algorithms! They make life SO much easier, especially on Dr. Racket! :)
2) Transforming Images:
- Flipping an image left or right (written as: (flip-main (p))- flips image on its left-hand side, and (flip-other (p)) flips image right-hand side
- Alt +P allows you to edit images that you've already used
- Scaling images (changing their size) (written as: (scale 3 (p))- meaning: scale the following image, (p) to 3 times its original size, or (scale 1/3 (p))- meaning: scale the following image (p) to 1/3 its original size.
- Scaling images with "x" and "y" dimensions separately, "x" meaning height, and "y" meaning width by typing: (scale/xy 2 1/2 (p)). 2 applies to "x" and 1/2 applies to "y").
- Rotating images (rotate 180 (p))- meaning rotate (p) 180 degrees
Something I enjoyed about this section was how easy it was to scale separate dimensions of an image. This was great to learn because it is exact, unlike using the Microsoft Word cursor to make images a certain size; you simply type how much you need each dimension to be scaled by, and Dr. Racket scales it! Wonderful! :) Did I mention that I LOVE algorithms?! ;)
ALL CREDIT goes to the YouTube channel "Danny Heap", who is my Professor:
3) Combining Values:
- Overlaying images: (overlay (p1) (p2)). (p1) meaning the first image, (p2) meaning the second image, and so forth...
- Combining numbers with addition and multiplication: (+ 1 2 3 4) --> 10, and (* 1 3) --> 3. The "*" sign, in this case, means to multiply the numbers that follow that symbol
- Finding quotients (number of times one number goes into another): (quotient 9 3), meaning: how many times does 3 go into 9? --> 3
- Using the former (finding quotients) to find remainders! I.e. for how many times 9 goes into 24, first type (quotient 24 9)--> 2. Then, type (remainder 24 9)--> 6 (So, 24/9= ~2.6).
- Combining strings (from 1). Use (string- append "hi" "my" "name" "is" "short") --> himynameisshort (like Twitter hash-tags!)
- I learned to ask if numbers are equal, and the result was either "true" or "false". i.e. (equal? 3 9) --> false
- Asking whether 1<3<2: (< 1 3 2) --> false
:S - Asking whether 1/2 is less than or equal to 1... (or (< 1/2 1) (equal? 1/2 1)) --> true. --> I STILL DON'T FULLY UNDERSTAND THIS INSTRUCTION, so I accept this as a challenge, even though it frustrates me to no end. I will ask how to solve this and explain what is meant by the function (or (< 1/2 1) (equal? 1/2 1)) NEXT WEEK! So stay tuned!
:S - Asking whether 1/2 is less than AND equal to 1 (and (<1/2 1) (equal? 1/2 1)) --> false (See above for the "or" --> I'm still confused!
I plan to solve these understanding issues by asking my Instructor(s) for help, as well as looking over my notes, asking friends in the class to explain the concepts to me, and/or watching the videos provided for Combining Values.
I enjoyed finding quotients easily because I usually take quite a long time to find quotients AND remainders of numbers without a calculator! I got very frustrated because I couldn't understand two commands, but will be sorting this problem out for next week! :)
ALL CREDIT goes to the YouTube channel "Danny Heap", who is my Professor:
4) Decomposing Values:
- Finding how many pixels wide an image is: (image- width (p)), or (image- height (p))
- Getting sum of image by cropping off top of image: (crop- top 100 (p)) - 100 means crop 100 pixels off the top of the image. Similarly, you can crop pixels off the left/ right/ etc. of the image by replacing the "top" with "left/ right/ etc."
- Cropping numbers (like pi or "e"): (round e) --> #i3.0 (#i means 3.0 is not an exact number)
- Converting inexact to exact: (inexact->exact #3.0) --> 3
- Rounding down to nearest integer: (floor e) --> #i2.0
- Pulling out numbers in a substring: (substring 01290192 2 4)- means pull out numbers 2-4 from the list given (01290192), BUT start counting numbers FROM ZERO and don't include the 4th number!! Solution: "2 9". This works for letters as well.
I enjoyed learning how to crop images on Dr. Racket because I can't always find the crop tool on Microsoft word, so this is very convenient! :)
ALL CREDIT goes to the YouTube channel "Danny Heap", who is my Professor:
Also, the Fibonacci sequence was converted into Dr. Racket language as follows:
(define (fib n)
(if
(< n 2)
n
(+ (fib (- n 1)) (fib (- n 2)))))
ALL CREDIT goes to Danny Heap, who provided the class with this endlessly useful and interesting method of defining the sequence!
I feel quite confident about material covered this week, and enjoyed learning how to use algorithms! Also, I really like this course so far because I can relate the material to using technology, which is my goal. I want to understand what I'm using in terms of computing and technology in general!
One of my achievements this week was learning how to use many functions in Dr. Racket! :D
My test went well this week, and hopefully this assignment (my SLOG) will go well as well!
That's it for this week! :)