racket
racket copied to clipboard
Add reverse-string approaches
@ErikSchierboom, here are the three approaches I'm looking at. Before I fill these out further, do you think the substring and index-based techniques are different enough to justify separate approaches?
does the reversing-by-index approach also use recursion? I don't see it used explicitly, but it probably is there?
No, build-string internally makes a string of N length and then loops over the indices to update each element. See https://github.com/racket/racket/blob/05c3fe4a92bb7d310675d2ffda2d55fdd24a596a/racket/collects/racket/private/list.rkt#L303. I can tweak that approach to use string-set! explicitly to make it clear there's no recursion.