Camel case and snake case: Difference between revisions
Content added Content deleted
Alextretyak (talk | contribs) (Added 11l) |
(Added Quackery) |
||
Line 1,191: | Line 1,191: | ||
spaces => spaces |
spaces => spaces |
||
</pre> |
</pre> |
||
=={{header|Quackery}}== |
|||
<lang Quackery> [ $ "_ -" find 3 < ] is separator ( c --> b ) |
|||
[ dup lower != ] is capital ( c --> b ) |
|||
[ $ "" false rot |
|||
witheach |
|||
[ dup separator iff |
|||
[ 2drop true ] |
|||
else |
|||
[ over if upper |
|||
swap dip join |
|||
drop false ] ] |
|||
drop ] is camelise ( $ --> $ ) |
|||
[ camelise |
|||
$ "" swap |
|||
witheach |
|||
[ dup capital if |
|||
[ dip |
|||
[ char _ join ] ] |
|||
lower join ] ] is snakify ( $ --> $ )</lang> |
|||
{{out}} |
|||
Testing in the shell. |
|||
<pre>/O> ' [ $ "snakeCase" |
|||
... $ "snake_case" |
|||
... $ "variable_10_case" |
|||
... $ "variable10Case" |
|||
... $ "ergo rE tHis" |
|||
... $ "hurry-up-joe!" |
|||
... $ "c://my-docs/happy_Flag-Day/12.doc" |
|||
... $ " spaces " ] |
|||
... dup |
|||
... say "To camelCase:" cr cr |
|||
... witheach [ do camelise echo$ cr ] cr |
|||
... say "To snake_case:" cr cr |
|||
... witheach [ do snakify echo$ cr ] cr |
|||
... |
|||
To camelCase: |
|||
snakeCase |
|||
snakeCase |
|||
variable10Case |
|||
variable10Case |
|||
ergoRETHis |
|||
hurryUpJoe! |
|||
c://myDocs/happyFlagDay/12.doc |
|||
Spaces |
|||
To snake_case: |
|||
snake_case |
|||
snake_case |
|||
variable10_case |
|||
variable10_case |
|||
ergo_r_e_t_his |
|||
hurry_up_joe! |
|||
c://my_docs/happy_flag_day/12.doc |
|||
_spaces |
|||
Stack empty.</pre> |
|||
=={{header|Raku}}== |
=={{header|Raku}}== |