[Programming] Scheme and it’s virtues

I took this class, that was a survey of different programming languages. PHP, Ruby, Perl, Python, Scheme, and Java (Android Development). It was fast and fun, at the end of every week, depending on concept you either knew the languge enough to write symple code about it, or were taught a programming concept from it.

After the class I continued trying to solve different mathematical problems with scheme using extremely large inputs.

This is a simple problem, convert a decimal to a hexadecimal. The code is self explanatory but here's a list of my lessons learned through this excercise.

Scheme is a Functional Programming language.

1- Types are essential.
this function accepts a number, or an integer. Both types aren't mutually exclusive, depending on your implementation this fact is gold. the returning type is also what allows for the recursion to take place, hence funtion expecting same input type at every iteration

2- error checking
the success of the simple function is checking for errors, on input, and making it separate from the recursion process

3- recursion
you do not appreciate a base case, until you have a complex scheme problem to solve. Your base case is everything. In this example. I append the remainder to the result. getHex is a simple function that prints a Hex character, or numbers, for each iteration until it has reached it's base case.

4- variables
this also teaches you discipline. In other forms of programming, you have the luxury of saving the quotient and using it at every iteration, but the scheme methodology is to calculate the quotient recursively over the remainder, backwards.

5- design
How can you append recursively backwards? Most classic recursions examples move forward, now in this example, I create a two argument function, that places the hex digit first in the output but also recognizes, the dec variable needs to remain a number through the iterations.