Skip to content

Instantly share code, notes, and snippets.

@lucidguppy
Last active August 29, 2015 14:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lucidguppy/d01fb6d4f2522edbadad to your computer and use it in GitHub Desktop.
Save lucidguppy/d01fb6d4f2522edbadad to your computer and use it in GitHub Desktop.
Output hello 10 times with counter
#string interpolation is similar to python - be sure to import string utils
import strutils
var output = "a $1 parrot" % ["dead"]
echo(output)
for time in countUp(1,10):
echo("I like traffic lights $time" % ["time", intToStr(time)])
echo("But only when they're green")
import strutils
if contains("exterminate","term"):
echo("DESTROY!!!")
if "x" in "exterminate":
echo("EXTERMINATE!")
#iterate over string
var greeting = "Always look on the bright side of life."
for c in greeting:
echo(c)
#indexing and slicing
echo("-------------------------")
echo(greeting[4])
echo(greeting[4..10])
echo(greeting[..14])
#print out ten lines
for x in countup(1,10):
echo("hello: ", x)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment