[racket] newbie string handling problem

From: Charles Hixson (charleshixsn at earthlink.net)
Date: Thu Mar 31 19:38:26 EDT 2011

Hi,
I'm trying to determine whether the last non-whitespace character of a 
string is a colon, and I haven't been able to figure out the best way of 
doing this.  In python I'd just trim the string and look at the 
character before the end, but while Racket seems to have a string-length 
function, it doesn't seem to have anything analogous to trim.  So how 
should it be done?

The best I've come up with is to explode the string into a list of 
characters, and handle it that way, but that's clearly quite wasteful of 
both processing and RAM.  (Of course, part of it is that the best way 
I've figured to proceed from there is to then copy that list to another 
list checking at each step of the way to tell if I was done, and then if 
it was successful to join the resultant list back into a string.)


Posted on the users mailing list.