grid = f (0,0) where f (x,y) = (x,y) : f next where next | x == 0 && y == 0 = right | x > 0 && y <= 0 = down | x <= 0 && y < 0 = left | x < 0 && y >= 0 = up | x >= 0 && y > 0 = right left = (x-1,y) right = (x+1,y) up = (x,y+1) down = (x,y-1) main = do
Standard input is empty
[(0,0),(1,0),(1,-1),(0,-1),(-1,-1),(-1,0),(-1,1),(0,1),(1,1),(2,1),(2,0),(2,-1),(2,-2),(1,-2),(0,-2),(-1,-2),(-2,-2),(-2,-1),(-2,0),(-2,1),(-2,2),(-1,2),(0,2),(1,2),(2,2)] [(0,0),(1,0),(1,-1),(0,-1),(-1,-1),(-1,0),(-1,1),(0,1),(1,1),(2,0),(0,-2),(-2,0),(0,2)]