Abstract. This is the solution to the letter case conversion exercise. |
![]() ![]() ![]() 1 Introduction As for other exercises, we point a solutions in a LAML library file, here general in lib4/general.scm |
1.1 capitalize-string 1.2 upcase-a-string 1.3 down-case-string |
![]() ![]() ![]() 1.1 capitalize-string |
In the general library we both support destructive procedures and pure functions for letter conversion puposes. In this story, we are only concerned with the pure functions. Somehow I have regretted that I ever made the mutator procedures...
As a consequence I will here show good functional solutions, aided by some primitive functions in the general library.
First the function capitalize-a-string. If the input string is empty we decide that the result is also the empty string. As such, we go for a weak pre condition.
If the string is non-empty we capitalize the first character by capitalize-char from the general library. The as-string'ed first capitalized char is then string-appended to the suffix substring of str. That is it!
![]() ![]() ![]() 1.2 upcase-a-string |
![]() ![]() ![]() 1.3 down-case-string |