Skip to content

Commit 7b2da8e

Browse files
committed
Merge branch 'master' of github.com:qiwsir/algorithm
2 parents 149c9f4 + 0e44268 commit 7b2da8e

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

string_to_hump.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,28 @@
2929

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

32+
###racket解决方法 (racket 5.2.1)
33+
34+
```racket
35+
#lang racket
36+
37+
; 定义字符串转换函数 train-to-camel
38+
(define (train-to-camel train-str separator-char)
39+
(let
40+
[(splited-str (regexp-split separator-char train-str))] ; 把原始字符串用 '-' 分成多个单独的单词
41+
(string-append
42+
(first splited-str)
43+
(apply
44+
string-append
45+
(map
46+
string-titlecase
47+
(rest splited-str))))))
48+
49+
; 调用字符串转换函数 train-to-camel
50+
(train-to-camel "this-is-a-var" "-") ; 正常运行的情况下, 应输出 "thisIsAVar"
51+
52+
```
53+
3254
--------------
3355

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

0 commit comments

Comments
 (0)