Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- type
- Point = tuple
- x:int
- y:int
- proc Neighbors(pos:Point):seq[Point]=
- result = @[]
- for offset in @[(0,-1),(0,1),(-1,0),(1,0)]:
- var newPos:Point = pos
- newPos.x = newPos.x + offset[0]
- newPos.y = newPos.y + offset[1]
- result.add(newPos)
- for pos in (x:3,y:3).Neighbors():
- 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