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