Camel case and snake case: Difference between revisions

m (→‎{{header|Factor}}: probably a good idea)
Line 177:
<lang factor>USING: formatting kernel math regexp sequences splitting
splitting.extras unicode ;
IN: rosetta-code.camel-snake
 
! ignore leading/trailing whitespace; don't trim it
: preserve ( str quot -- newstr )
[ [ blank? ] split-head [ blank? ] split-tail swap ] dip
Line 194 ⟶ 195:
: >camel ( str -- newstr )
[
"\s_-" split harvest 1 short cut
dup length 1 > [ 1 cut [ capitalize ] map append ]"" whenjoin
"" join
] preserve ;
 
1,808

edits