University so far has been interesting. Tomorrow morning I will write my final Final Exam for this term, for CS 135. Scheme is the language we used in this course and it’s very minimalistic as far as programming languages go. The basic tools/functions are designed in such a way as to make creation of new tools and functions very easy. This is what I like most about Scheme.
4 Scheme built-in functions and what they do:
- (cond [question1 answer1] [question2 answer 2]…)
cond is basically an IF and THEN statement. You ask a question, if it’s true, you do whatever the corresponding answer is. If it’s false, you ask the next question. - (cons something list) / (list something1 something2…)
cons makes lists. The “something” can be anything, be it a number, a word/string, a symbol, another list, etc… The second thing (the list part) is any list, so some other cons item, or the item “empty” (which is the basic, ending item for a list). list can be used in its place for simplicity’s sake. - (define name something)
This define is used to give a name to something. You could define the name Carl as the string “awesome problem child”, so that later when you enter or call Carl, you’ll get “awesome problem child” back. This can be useful for giving short names for long expressions/things. - (define (function variable1 variable2…) expression)
This define is used differently, to name a function with a certain number of variables. The following expression with use these variables to do calculations or make changes to them or whatever. This is tantamount to defining “y” as something in terms of “x”, maybe “z”, and possibly, if you’re lucky, there’s a “w” somewhere in there. When the function is called, that’s when you also give it values (like numbers or words) to use as the variables (like saying “let ‘x’ be 50″).
And that’s pretty much it. With those and a few basic predicate functions (like =, >, <, equal?, etc…) you can build a surprisingly large variety of functions and applications that run on a lot of different kinds of inputs, generating a lot of different kinds of output too. You can even use and generate functions as input and output. Exciting, I’m sure.
Anyway, tomorrow’s the exam and I’ve somehow managed to waste most/all of today on reading blog feeds and anything else that isn’t studying. how foolish. My dad seems to have faith in it being a “piece of cake, right?” for me so I now I should have to do well. As long as they do not tell me to do any intensely complicated abstraction of functions, I should be able to do quite decently. Here’s to gambling!
Note: Click here for the photos on flickr of Hermes in LEGO form.