version 0.7.4
This commit is contained in:
parent
1c8ddca7e0
commit
439aa2d04d
114 changed files with 13664 additions and 10110 deletions
|
|
@ -1,7 +1,11 @@
|
|||
# Hallo
|
||||
|
||||
import
|
||||
os
|
||||
os, strutils, macros
|
||||
|
||||
type
|
||||
TMyEnum = enum
|
||||
meA, meB, meC, meD
|
||||
|
||||
when isMainModule:
|
||||
{.hint: "this is the main file".}
|
||||
|
|
@ -9,7 +13,7 @@ when isMainModule:
|
|||
proc fac[T](x: T): T =
|
||||
# test recursive generic procs
|
||||
if x <= 1: return 1
|
||||
else: return x * fac(x-1)
|
||||
else: return x.`*`(fac(x-1))
|
||||
|
||||
macro macrotest(n: expr): stmt =
|
||||
expectKind(n, nnkCall)
|
||||
|
|
@ -35,22 +39,41 @@ echo("This was compiled by Nimrod version " & system.nimrodVersion)
|
|||
writeln(stdout, "Hallo", " World", "!")
|
||||
|
||||
echo(["a", "b", "c", "d"].len)
|
||||
for x in items(["What's", "your", "name", "?"]):
|
||||
for x in items(["What's", "your", "name", "?", ]):
|
||||
echo(x = x)
|
||||
var `name` = readLine(stdin)
|
||||
{.breakpoint.}
|
||||
echo("Hi " & thallo.name & "!\n")
|
||||
debug(name)
|
||||
|
||||
var testseq: seq[string] = @[ "a", "b", "c", "d", "e"]
|
||||
var testseq: seq[string] = @[
|
||||
"a", "b", "c", "d", "e"
|
||||
]
|
||||
echo(repr(testseq))
|
||||
|
||||
var dummy = "hallo"
|
||||
echo(copy(dummy, 2, 3))
|
||||
|
||||
echo($meC)
|
||||
|
||||
# test tuples:
|
||||
for x, y in items([(1, 2), (3, 4), (6, 1), (5, 2)]):
|
||||
echo x
|
||||
echo y
|
||||
|
||||
# test constant evaluation:
|
||||
const
|
||||
constEval = "abc".contains('b')
|
||||
constEval2 = fac(7)
|
||||
|
||||
echo(constEval)
|
||||
echo(constEval2)
|
||||
echo(1.`+`(2))
|
||||
|
||||
for i in 2..6:
|
||||
for j in countdown(i+4, 2):
|
||||
echo(fac(i * j))
|
||||
|
||||
when isMainModule:
|
||||
{.hint: "this is the main file".}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue