Question: write scheme program (xyz.scm) [5 marks] Write a procedure called (palindrome? s) that takes a string s as argument and returns true (#t) if s

write scheme program (xyz.scm)
  1. [5 marks] Write a procedure called (palindrome? s) that takes a string s as argument and returns true (#t) if s is palindrome.
  2. [7 marks] A k-palindrome is a string that can be made into a palindrome by ignoring up to k characters. Write a procedure called (k-palindrome? s k) that takes a string s and a non-negative integer k as arguments and returns true if s is a k-palindrome. For example,

(k-palindrome? "tahcohcat" 2) -> #t

(k-palindrome? "tahcohcat" 1) -> #f

You may find the following built-in procedures useful for the above problems:

  • (string-length str) - returns the number of characters in a given string
  • (string-ref str i) - returns the character at a specified index in a given string
  • (substring str start [end]) - returns a substring of a given string between two indices [the ending index is opti

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!