Fix splitByAll side effect
This commit is contained in:
@@ -1,15 +1,17 @@
|
||||
(doFor name [
|
||||
"Finn"
|
||||
"Miguel"
|
||||
"George"
|
||||
"Ernest"
|
||||
"Crawford"
|
||||
"Howard"
|
||||
"Troy"
|
||||
"Tracy"
|
||||
"Valeria"
|
||||
"Vanessa"
|
||||
]
|
||||
(assert (Names.isName name)))
|
||||
(doFor _ (range 2)
|
||||
(doFor name [
|
||||
"Finn"
|
||||
"Miguel"
|
||||
"George"
|
||||
"Ernest"
|
||||
"Crawford"
|
||||
"Howard"
|
||||
"Troy"
|
||||
"Tracy"
|
||||
"Valeria"
|
||||
"Vanessa"
|
||||
]
|
||||
(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]
|
||||
(if delims
|
||||
(ifLet [delims (delims.copy)]
|
||||
(let [next (delims.shift)
|
||||
tokens (text.split next)]
|
||||
(flatten (for token tokens (splitByAll token (delims.copy)))))
|
||||
|
Reference in New Issue
Block a user