Fix splitByAll side effect

This commit is contained in:
2023-03-20 21:04:27 -06:00
parent 7ceff56bd7
commit 2bb33fd8fc
2 changed files with 17 additions and 15 deletions

View File

@@ -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..."))
)

View File

@@ -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)))))