`do' keyword in the grammar for lambda blocks

This commit is contained in:
Zahary Karadjov 2012-02-10 14:50:06 +02:00
commit 560a3bad28
14 changed files with 83 additions and 36 deletions

View file

@ -12,6 +12,10 @@ proc foldr(n: openarray[int], fn: proc (x, y: int): int {.closure}): int =
for i in 0..n.len-1:
result = fn(result, n[i])
proc each(n: openarray[int], fn: proc(x: int) {.closure.}) =
for i in 0..n.len-1:
fn(n[i])
var
myData: array[0..4, int] = [0, 1, 2, 3, 4]
@ -24,8 +28,10 @@ proc testA() =
inc(p))
testA()
for x in items(myData):
myData.each do (x: int):
write(stout, x)
#OUT 2 4 6 8 10