Scheme of things

Unfortunately I did not attend MIT, and Scheme was not taught to us as one of the first languages 🙂 . Our college used Prolog for similar purpose and I learned scheme much later. When I first started out what intrigued me most was that its one of the oldest launguages around and was still holding ground. It was developed in 1975 a year before I was born and in the field of computing things seldom stick for so long.

After taking a brief look into the syntax I figured out this is not one of those languages where you try out “Hello world” first. I brought up the DrScheme IDE and tried out (/ 22 7) which is supposed to print out 22 divided by 7. I was surprised that to get back 3 1/7 and not something like 3.1428.

The results of the next attempt was even for interesting. I tried out (% 22 7). This was a typo as there is no % operator in Scheme. The Scheme interpreter actually displayed the imageof a bug to indicate there was a bug in the code I typed. Whenever I get a VSTS bug assigned to me on some improper/ambiguous/funny error messages I always feel like showing that person this message 🙂

DrScheme Screen shot

Comments (1)

  1. amitchat says:

    Prolog and Scheme are actually quite different. Prolog belongs to a class of ‘logic programming language’.

    Scheme has the ability to express numbers in their EXACT form (without approximation). Most of the primitive operations will yield in EXACT numbers or rationals. Note, that it is not mandatory that the Scheme implementation must express numbers in the exact form. I believe you can convert the exact number into the decimal form by using something like

    (exact->inexact <fraction>)

    I remember that the biggest mind bend that you have get across while doing functional programming is using recursion to do all your work. Coming from a procedural language, I had to spend some time getting my head to adjust to using recursion for doing a simple loop. You will know you have it figured when you manage to do a Pascal’s triangle 🙂