Friday, November 12, 2010

In which we get our first official repetition lesson

Ne, ne, I can actually hit the target now! Sort of. Well...my best hit rate was 75%.
Grah...what am I saying? I'm still horrible.

Anyways, today we finally got to learn about repetition! The first thing Mr. Arkin showed us was a program that continued to show the text "Hello, world!" on one corner of the screen after another. He didn't show us the code, but instead moved on to teach us about loop.

When a certain action or actions need to be repeated, we use the loop procedure. Everything in the loop body gets repeated over and over until a certain condition is met. All the major actions that are repeated are inside what's called the loop body. To instruct the computer when to stop repeating these actions, you use the keywords exit when.

For example:

loop
     put i

     i := i + 1

     delay (1500)

     exit when i > 13

end loop

Yep. Except in here, "13" and "1500" are magic values. Normally you would use a constant (or variable, depending on the type of program) in their places.

As for what this program does, it simply incrememnts i (a given integer) by one every 1.5 seconds.
When i is greater than thirteen (in other words, when i is equal to 14), the computer stops looping these actions and performs the next action, if there is any. If not, then the program is finished.

Simple, ne? And I finished all the homework, too! Now all I have to do on the weekend is my science. And I want to draw a picture for Jessie's birthday, as well as continue my Durarara!! fic.

I wish Durarara!! had more backgrounds. I'm changing my background today (this morning?) because the current one is just too busy. I wanted to use a picture from DN Angel, seen below, but I couldn't find a...er, bigger one.

Risa-chan!
DN Angel belongs to Yukiru Sugisaki.
Therefore...I'm using my old Fate/Stay Night wallpaper. Hopefully you guys like it (yes, I really do care about that).

That's all I have to say about today. I've been feeling very...depressed these days. So, don't mind me if I suddenly slip into a younger version of myself. It's normal.

Ah, well. I should go to sleep now. I'll just change my background first. Sweet dreams, minna-san!

No comments:

Post a Comment