Rocking the blogosphere
Apple Online Store

camel-case-from-underscored

Continuing Marc’s exploration of Lisp, today we present a Scheme function that might be marginally useful:

(define (camel-case-from-underscored underscored-name)
  (regexp-substitute/global #f "_"
    (string-capitalize underscored-name) 'pre 'post))

Here’s it in action - try to contain your excitement:

$ guile
guile> (load "string_stuff.scm")
guile> (camel-case-from-underscored "super_cool_button")
"SuperCoolButton"

Books on Lisp from Amazon.com

The Little Schemer - 4th EditionThe Seasoned SchemerPractical Common Lisp

Del.icio.us Digg Reddit Technorati

Possibly related posts

Comments

  1. March 19th, 2006 | 4:05 pm

    Now, for a real challenge: make a function that will convert back and forth between the two formats. ;-)

Leave a reply

Apple Online Store
Apple Online Store