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

One thought on “camel-case-from-underscored

Leave a Reply

Your email address will not be published. Required fields are marked *