Add tasks for all the new languages
This commit is contained in:
parent
9dc3c2bb62
commit
bba7bfd280
13208 changed files with 134745 additions and 0 deletions
19
Task/Multisplit/Nim/multisplit.nim
Normal file
19
Task/Multisplit/Nim/multisplit.nim
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
import strutils
|
||||
|
||||
iterator tokenize(text, sep): tuple[token: string, isSep: bool] =
|
||||
var i, lastMatch = 0
|
||||
while i < text.len:
|
||||
for j, s in sep:
|
||||
if text[i..text.high].startsWith s:
|
||||
if i > lastMatch: yield (text[lastMatch .. <i], false)
|
||||
yield (s, true)
|
||||
lastMatch = i + s.len
|
||||
i += s.high
|
||||
break
|
||||
inc i
|
||||
if i > lastMatch: yield (text[lastMatch .. <i], false)
|
||||
|
||||
for token, isSep in "a!===b=!=c".tokenize(["==", "!=", "="]):
|
||||
if isSep: stdout.write '{',token,'}'
|
||||
else: stdout.write token
|
||||
echo ""
|
||||
Loading…
Add table
Add a link
Reference in a new issue