Advertisement
Guest User

Untitled

a guest
Apr 26th, 2016
122
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Nim 0.40 KB | None | 0 0
  1.  
  2. type
  3.     Point = tuple
  4.         x,y: int
  5.  
  6. proc Neighbors(pos:Point):seq[Point]
  7.  
  8. var point:Point = (x:3, y:3)
  9.  
  10. for pos in point.Neighbors():
  11.     echo $pos
  12.  
  13. proc Neighbors(pos:Point):seq[Point] =
  14.     result = @[]
  15.     for offset in @[(0,-1),(0,1),(-1,0),(1,0)]:
  16.         var newPos = pos
  17.         newPos.x = newPos.x + offset[0]
  18.         newPos.y = newPos.y + offset[1]
  19.         result.add(newPos)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement