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
26
Task/Substring/Nim/substring.nim
Normal file
26
Task/Substring/Nim/substring.nim
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
import strutils
|
||||
|
||||
let
|
||||
s = "abcdefgh"
|
||||
n = 2
|
||||
m = 3
|
||||
c = 'd'
|
||||
cs = "cd"
|
||||
var i = 0
|
||||
|
||||
# starting from n=2 characters in and m=3 in length
|
||||
echo s[n-1 .. n+m-2]
|
||||
|
||||
# starting from n characters in, up to the end of the string
|
||||
echo s[n-1 .. s.high]
|
||||
|
||||
# whole string minus last character:
|
||||
echo s[0 .. <s.high]
|
||||
|
||||
# starting from a known character c='d'within the string and of m length
|
||||
i = s.find(c)
|
||||
echo s[i .. <i+m]
|
||||
|
||||
# starting from a known substring cs="cd" within the string and of m length
|
||||
i = s.find(cs)
|
||||
echo s[i .. <i+m]
|
||||
Loading…
Add table
Add a link
Reference in a new issue