Hello, and thank you for helping me today! I am working on a scheme procedure that takes a string as its input, capitalizes every letter in the string, and then prints out the result. This is a homework assignment, and we are supposed to use another procedure that we wrote earlier on, which capitalizes a single character entered by the user. This procedure, which I wrote and which works fine, is included at the top of my current procedure. Right now, I have the following:
; defining the procedure char_toupper to convert a lower case character to upper case (define char_toupper (lambda (myChar) ; defining x as the ASCII value of myChar (define x (char->integer myChar)) ; defining y as x-32 (define y (- x 32)) ; if statement for while x is less than 91 (already uppercase) (if (< x 91) ; if it is already uppercase, just display it (display myChar) ; otherwise, if x is greater than 96 (lowercase) (if (> x 96) ; then display the character equivalent to the ASCII value given by y (display (integer->char y)) ) ) ) ) (define string_toupper (lambda (myString newString i) (if (< i (string-length myString)) (string_toupper myString (string-append newString (char_toupper (string-ref myString i))) (+ 1 i)) ) (display newString) ) ) (string_toupper (read) "" 0)
But it is not working. I get an error when I run the procedure, which says this: "string-append: expects type <string> as 2nd argument, given: #<void>; other arguments were: """
What am I doing wrong here? Can someone help me with this?
Thank you in advance!