Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions string_to_hump.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,28 @@

##欢迎补充其它语言的解决方法

###racket解决方法 (racket 5.2.1)

```racket
#lang racket

; 定义字符串转换函数 train-to-camel
(define (train-to-camel train-str separator-char)
(let
[(splited-str (regexp-split separator-char train-str))] ; 把原始字符串用 '-' 分成多个单独的单词
(string-append
(first splited-str)
(apply
string-append
(map
string-titlecase
(rest splited-str))))))

; 调用字符串转换函数 train-to-camel
(train-to-camel "this-is-a-var" "-") ; 正常运行的情况下, 应输出 "thisIsAVar"

```

--------------

###联系我:老齐 qiwsir#gmail.com (# to @)