Language BSL - DrRacket (racket variant)
Problem: I need to understand what the function below does exactly. Specifically the substring bit, I don't understand how it determines whether a string has an "?" at the end in choosing whether to append "?" to the consumed string.
(define (ensure-question str)
(if (string=? (substring str (- (string-length str) 1)) "?")
str
(string-append str "?")))