racket icon indicating copy to clipboard operation
racket copied to clipboard

Add reverse-string approaches

Open BNAndras opened this issue 1 year ago • 1 comments

@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?

BNAndras avatar Jan 22 '24 06:01 BNAndras

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.

BNAndras avatar Jan 22 '24 19:01 BNAndras