I don't think there's a library function that does what you want, so you'd
need to define your own. Here's one way to do it:

(define (capitalize-first-letter str)
  (cond
    [(non-empty-string? str)
     (define first-letter-str
       (substring str 0 1))
     (define rest-str
       (substring str 1 (string-length str)))
     (string-append (string-upcase first-letter-str)
                    rest-str)]
    [else
     ""]))

-Philip

On Mon, Jun 19, 2017 at 5:12 PM, Glenn Hoetker <ghoet...@gmail.com> wrote:

> I'm quite new to Racket/LISP, so I hope this isn't breathtakingly
> obvious.  Can someone please tell me the best way to capitalize just the
> first word in a multiword string.  So, given the string "it was a dark and
> stormy night", I would like to get "It was a dark and stormy night". I see
> functions for turning everything lower case, everything uppercase or
> capitalizing each word, but nothing in line with what I hope to do.
>
> > (define it "cat dog")
> > (string-titlecase it)
> "Dog Cat"  ; So close, but not quite "Dog cat" as I want.
>
> Many thanks.
>
>
> --
> You received this message because you are subscribed to the Google Groups
> "Racket Users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to racket-users+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to