On Fri, Oct 21, 2022 at 11:26:05AM +0200, [email protected] wrote: > See #1809, as suggested by Zipheir.
Thanks, pushed! I also took the liberty of adding Zipheir to the acknowledgments and adding the change to the NEWS file. > + (define (string-trim str) > + (let loop ((front 0) > + (back (sub1 (string-length str)))) > + (cond ((= front back) "") > + ((char-whitespace? (string-ref str front)) > + (loop (add1 front) back)) > + ((char-whitespace? (string-ref str back)) > + (loop front (sub1 back))) > + (else (substring str front (add1 back)))))) I was a bit surprised to remember that we don't really have this in (chicken string), all we have is the somewhat whimsical string-chomp. First I thought maybe moving this definition to (chicken string), but then I realised we probably want to at least somehow specify what's considered whitespace, but then you end up with a slow implementation. And we do have a version of this in srfi-13 (which includes a predicate/char-set argument), so maybe we don't really need it after all. But still, it's a bit weird not to have this in the standard lib... What do the other hackers think? Cheers, Peter
signature.asc
Description: PGP signature
