After learning a bit more about Lisp, I decided to dig into functional programming. Next up on the list is Hello World in Scheme, a minimalist dialect of Lisp.
Table of Contents
Once again, I took to Wikipedia to learn more about the new language.
According to Wikipedia, Scheme is the minimalist branch of Lisp. The only indicator of minimalism in Scheme I can find is the fact that it features only 23 s-expressions. Unfortunately, I wasn’t able to find any additional information on what makes scheme so simple. Let me know in the comments.
In terms of features, Scheme leverages lambda calculus, lexical scoping, tail recursion, and first-class continuations. To be honest, I had to research lexical scoping. Turns out, lexical scoping is just a fancy name for static scoping. In other words, variables only exist within the block of text that they’re defined. In contrast, Common Lisp supports both lexical and dynamic scoping.
Despite Scheme appearing back in 1970, it’s still used today for primarily educational purposes. For instance, many universities use Scheme in their introductory programming courses. Beyond education, Scheme is mainly used by hobbyists for scripting purposes.
Hello World in Scheme
At long last, here’s an implementation of Hello World in Scheme:
(display "Hello, World!")
If you checked out the tutorial on Hello World in Lisp, then this should be easy. First things first, we have the display function. The display function works exactly as you would expect. It takes some input and displays it to the user.
As a result, it’s natural to expect that the input in this case is Hello World. All we do is pass the Hello World string to display, and we’re done.
How to Run the Solution
As usual, we can give it a go with an online Scheme interpreter. Just drop the code above into the editor and hit run.
csi -s hello-world.scm
That will run the Scheme file as a script which will quickly print the “Hello, World!” string.
Sample Programs in Every Language
And, that’s it! We’re all done with Hello World in Scheme.
Since we’re on the topic of Scheme, I’m actually interested in learning a bit about Racket. So, I think we’ll tackle Hello World in Racket next. Who knows what we’ll cover after that, but I want to try a few more functional languages before we move on. After all, we have time; we’re covering Hello World in Every Language!
Continuing in our computer science problem series, I figured we'd dive into a couple of fun Java topics: parameter passing and primitive types. Specifically, we'll be looking at whether or not you...
Today, I'm kicking off a series of new articles that take a look at real computer science multiple choice questions and attempt to give some tips for solving them. Right now, I want to start by...