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
10
Task/String-matching/Nim/string-matching.nim
Normal file
10
Task/String-matching/Nim/string-matching.nim
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
import strutils
|
||||
|
||||
var s: string = "The quick brown fox"
|
||||
if startsWith(s, "The quick"):
|
||||
echo("Starts with: The quick")
|
||||
if endsWith(s, "brown Fox"):
|
||||
echo("Ends with: brown fox")
|
||||
var pos = find(s, " brown ") # -1 if not found
|
||||
if contains(s, " brown "): # showing the contains() proc, but could use if pos!=-1:
|
||||
echo('"' & " brown " & '"' & " is located at position: " & $pos)
|
||||
Loading…
Add table
Add a link
Reference in a new issue