i need to define ‘string-right’
the procedure
(define string-right
(lambda (x)
(substring x (quotient (string-length x) 2) (string-length x))))
doesnt work on odd string lengths
but the prcoedure
(define string-right
(lambda (x)
(substring x (+ (quotient (string-length x) 2) 1)(string-length x))))
doesnt work on even string lengths. please help. frustrated.
assuming you meant you want the right half of a string without it’s middle:
in quotient (the first option), replace:
with:
if length of the string is even, then
floor((length + 1) / 2) = length / 2
otherwise
floor((length + 1) / 2) = (length + 1) / 2
the
+ 1part would exclude the middle elementthe full solution: