Fix splitByAll side effect
This commit is contained in:
@@ -1,3 +1,4 @@
|
|||||||
|
(doFor _ (range 2)
|
||||||
(doFor name [
|
(doFor name [
|
||||||
"Finn"
|
"Finn"
|
||||||
"Miguel"
|
"Miguel"
|
||||||
@@ -13,3 +14,4 @@
|
|||||||
(assert (Names.isName name)))
|
(assert (Names.isName name)))
|
||||||
|
|
||||||
(assertEquals 5 .length (Names.findNames "Vanessa, Finn, and Tracy--and George--go to Troy's..."))
|
(assertEquals 5 .length (Names.findNames "Vanessa, Finn, and Tracy--and George--go to Troy's..."))
|
||||||
|
)
|
||||||
@@ -27,7 +27,7 @@
|
|||||||
])
|
])
|
||||||
|
|
||||||
(function :Array<String> splitByAll [:String text :Array<String> delims]
|
(function :Array<String> splitByAll [:String text :Array<String> delims]
|
||||||
(if delims
|
(ifLet [delims (delims.copy)]
|
||||||
(let [next (delims.shift)
|
(let [next (delims.shift)
|
||||||
tokens (text.split next)]
|
tokens (text.split next)]
|
||||||
(flatten (for token tokens (splitByAll token (delims.copy)))))
|
(flatten (for token tokens (splitByAll token (delims.copy)))))
|
||||||
|
|||||||
Reference in New Issue
Block a user