Re: [racket] newbie string handling problem

2011-03-31 Thread Charles Hixson
Thanks. Regular expressions *isn't* what I wanted. (When I've tried them before [in Python] they made Python seem fast.) On 03/31/2011 05:06 PM, Thomas Chust wrote: 2011/4/1 Charles Hixson: [...] I'm trying to determine whether the last non-whitespace character of a string is a colon, an

Re: [racket] newbie string handling problem

2011-03-31 Thread Phil Bewig
; lnic -- last non-white is colon (define (lnic? s) ; explode to list (let loop ((cs (reverse (string->list s (cond ((null? cs) #f) ((char-whitespace? (car cs)) (loop (cdr cs))) (else (char=? (car cs) #\:) (define (lnic? s) ; index into string (let loop ((i (-

Re: [racket] newbie string handling problem

2011-03-31 Thread Matthias Felleisen
Here is what people are talking about when they say do it w/o regular expressions: #lang racket (require srfi/13) (define (ends-in-: s) (define t (string-trim-right s)) (and (> (string-length t) 0) (char=? (string-ref t (- (string-length t) 1)) #\:))) (ends-in-: "abc") (ends-in-: " abc

Re: [racket] newbie string handling problem

2011-03-31 Thread Neil Van Dyke
Eli Barzilay wrote at 03/31/2011 07:46 PM: Two minutes ago, Charles Hixson wrote: Hi, I'm trying to determine whether the last non-whitespace character of a string is a colon, (define (last-non-ws str) (cond [(regexp-match #px"(\\S)\\s*$" " \t") => cadr] [else #f])) then

Re: [racket] newbie string handling problem

2011-03-31 Thread Thomas Chust
2011/4/1 Charles Hixson : > [...] > 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, > [...] Hello, well,

Re: [racket] newbie string handling problem

2011-03-31 Thread Eli Barzilay
Two minutes ago, Charles Hixson wrote: > 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 Rack

Re: [racket] newbie string handling problem

2011-03-31 Thread Carl Eastlund
On Thu, Mar 31, 2011 at 7:38 PM, Charles Hixson wrote: > 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