Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Scheme Write a procedure in Scheme called charflip that takes a string as a para

ID: 3673821 • Letter: S

Question

Scheme

Write a procedure in 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..).

It is suggested 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

The function must be able to be called like so:

scheme@(guile-user)> (charflip "hatburg")

$16 = "hAtBuRg"

Explanation / Answer

The desired procedure is given below: In this procedure we have taken string as input then change the case of letters residing at odd postitions

Create procedure charflip @initialStr varchar(30)
as
begin

    Declare @i int, @length int, @outputStr varchar(30),@tempStr varchar(30)

    set @i=1
    set @outputStr=''

    select @length=length(@initialStr)

    while (@i<=@length )
    begin
        if (@i % 2 != 0)
        begin
            Select @tempStr= upper(substring(@initialStr,@i,1))
        end
     
        set @outputStr=@outputStr+@tempStr      
        set @i=@i+1
    end
select @outputStr
end

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote