Re: [Haskell-cafe] Infinite grid

2009-01-05 Thread Dan Weston
I think I found a solution to this, if you're still looking for one. See attached code. It uses a rose tree zipper where tree depth is manhattan distance from origin and forest width is nodes around concentric diamonds. The code is straightforward. Polar coords (RK) are stored in node label,

Re: [Haskell-cafe] Infinite grid

2009-01-02 Thread Martijn van Steenbergen
Henning Thielemann wrote: A dungeon game? :-) Yes. :-) Thank you all for your answers! I especially like David's no-intermediate-structure solution because it allows for defining the area in terms of neighbours instead of needing an index on the rooms. Now that I have core functionality

[Haskell-cafe] Infinite grid

2008-12-29 Thread Martijn van Steenbergen
Hello, I would like to construct an infinite two-dimensional grid of nodes, where a node looks like this: data Node = Node { north :: Node , east :: Node , south :: Node , west :: Node } in such a way that for every node n in the grid it doesn't matter how I travel to n, I

Re: [Haskell-cafe] Infinite grid

2008-12-29 Thread Luke Palmer
On Mon, Dec 29, 2008 at 3:55 PM, Martijn van Steenbergen mart...@van.steenbergen.nl wrote: Hello, I would like to construct an infinite two-dimensional grid of nodes, where a node looks like this: data Node = Node { north :: Node , east :: Node , south :: Node , west :: Node }

Re: [Haskell-cafe] Infinite grid

2008-12-29 Thread Henning Thielemann
Martijn van Steenbergen schrieb: Hello, I would like to construct an infinite two-dimensional grid of nodes, where a node looks like this: data Node = Node { north :: Node , east :: Node , south :: Node , west :: Node } in such a way that for every node n in the grid it

Re: [Haskell-cafe] Infinite grid

2008-12-29 Thread David Menendez
On Mon, Dec 29, 2008 at 5:55 PM, Martijn van Steenbergen mart...@van.steenbergen.nl wrote: Hello, I would like to construct an infinite two-dimensional grid of nodes, where a node looks like this: data Node = Node { north :: Node , east :: Node , south :: Node , west :: Node }

Re: [Haskell-cafe] Infinite grid

2008-12-29 Thread Dan Weston
I'm confused how this isn't just tantamount to using Data.Map (Integer,Integer) a. The essential problem is that you have an algebra acting on a topology. The algebra is easily rewritten to an efficient form, but a sequence of topological actions is not, because it is not sufficiently

Re: [Haskell-cafe] Infinite grid

2008-12-29 Thread David Menendez
On Mon, Dec 29, 2008 at 9:29 PM, Dan Weston weston...@imageworks.com wrote: I'm confused how this isn't just tantamount to using Data.Map (Integer,Integer) a. Data.Map.Map is strict in terms of structure. The number of elements in the map must be known and less than (maxBound :: Int). That