Advertisement
Guest User

Untitled

a guest
Apr 26th, 2016
117
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Nim 0.42 KB | None | 0 0
  1.  
  2. type
  3.     Point = tuple
  4.         x:int
  5.         y:int
  6.  
  7. proc Neighbors(pos:Point):seq[Point]=
  8.     result = @[]
  9.     for offset in @[(0,-1),(0,1),(-1,0),(1,0)]:
  10.         var newPos:Point = pos
  11.         newPos.x = newPos.x + offset[0]
  12.         newPos.y = newPos.y + offset[1]
  13.         result.add(newPos)
  14.  
  15. for pos in (x:3,y:3).Neighbors():
  16.     echo pos.x # this line fails with: test.nim(16, 13) Error: undeclared field: 'x'
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement