Lisp Scheme Write a procedure in Lisp Scheme called charflip that takes a string
ID: 3672930 • Letter: L
Question
Lisp SchemeWrite a procedure in Lisp Scheme called charflip that takes a string as a parameter and returns a copy of this string, flipping the case of every character in an odd position (index 1, 3, 5, etc..).
I suggest that you do this recursively. This means cons, car and cdr will come in handy, as will these functions:
• char-upper-case? • char-downcase • char-upcase • list->string • string->list
Here’s this function in action.
scheme@(guile-user)> (charflip "hatburg") $16 = "hAtBuRg" Lisp Scheme
Write a procedure in Lisp Scheme called charflip that takes a string as a parameter and returns a copy of this string, flipping the case of every character in an odd position (index 1, 3, 5, etc..).
I suggest that you do this recursively. This means cons, car and cdr will come in handy, as will these functions:
• char-upper-case? • char-downcase • char-upcase • list->string • string->list
Here’s this function in action.
scheme@(guile-user)> (charflip "hatburg") $16 = "hAtBuRg" Lisp Scheme
Write a procedure in Lisp Scheme called charflip that takes a string as a parameter and returns a copy of this string, flipping the case of every character in an odd position (index 1, 3, 5, etc..).
I suggest that you do this recursively. This means cons, car and cdr will come in handy, as will these functions:
• char-upper-case? • char-downcase • char-upcase • list->string • string->list
Here’s this function in action.
scheme@(guile-user)> (charflip "hatburg") $16 = "hAtBuRg"
Explanation / Answer
defun stringfun(x)
;case-sensitive comparison
(write(string ="sample lisp"))
(terpri)
"value of x"; This is a string
(-x))
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.