[Haskell-cafe] Re: Zippers

2009-03-07 Thread Heinrich Apfelmus
Cristiano Paris wrote: Heinrich Apfelmus wrote: ... Such self-reference is usually called tying the knot, see also http://www.haskell.org/haskellwiki/Tying_the_Knot I didn't know. Would you call this Tying the knot as well?

Re: [Haskell-cafe] Re: Zippers

2009-03-05 Thread Cristiano Paris
On 3/5/09, Ryan Ingram ryani.s...@gmail.com wrote: ... Here is the problem with your update: tree = Fork (Leaf 1) (Leaf 2) ztree = initZ tree test = fromJust $ do z1 - moveLeft ztree let z2 = update z1 3 z3 - moveUp z2 z4 - moveLeft z3 this z4 I'd expect test to equal

[Haskell-cafe] Re: Zippers

2009-03-05 Thread Heinrich Apfelmus
Cristiano Paris wrote: Ryan Ingram wrote: ... Here is the problem with your update: tree = Fork (Leaf 1) (Leaf 2) ztree = initZ tree test = fromJust $ do z1 - moveLeft ztree let z2 = update z1 3 z3 - moveUp z2 z4 - moveLeft z3 this z4 I'd expect test to equal 3, but I

Re: [Haskell-cafe] Re: Zippers

2009-03-05 Thread Cristiano Paris
On Thu, Mar 5, 2009 at 11:21 AM, Heinrich Apfelmus apfel...@quantentunnel.de wrote: ... Such self-reference is usually called tying the knot, see also  http://www.haskell.org/haskellwiki/Tying_the_Knot I didn't know. Would you call this Tying the knot as well?

[Haskell-cafe] Re: Zippers

2009-03-04 Thread Heinrich Apfelmus
Cristiano Paris wrote: I'm trying to catch the connection between delimited continuations and zippers so I wrote a (kinda) zipper interface to a simple tree structure. Here's the code: --- module Main where import Data.Maybe data Tree a = Leaf a | Fork (Tree a) (Tree a) deriving

Re: [Haskell-cafe] Re: Zippers

2009-03-04 Thread Cristiano Paris
On Wed, Mar 4, 2009 at 12:50 PM, Heinrich Apfelmus apfel...@quantentunnel.de wrote: ... The unusual thing about your implementation is probably that you're tying a knot by making both  moveUp  and  moveLeft  record fields. This reminds me of  Weaving a web. Ralf Hinze and Johan Jeuring.

Re: [Haskell-cafe] Re: Zippers

2009-03-04 Thread Cristiano Paris
On Wed, Mar 4, 2009 at 9:53 PM, Cristiano Paris fr...@theshire.org wrote: ... Thank you for any further comments. I forgot to mention one drawback I found in my implementation: it can't be (de)serialized to a String, which is clearly possible with Huet's. I think this accounts for the Zipper as

Re: [Haskell-cafe] Re: Zippers

2009-03-04 Thread Ryan Ingram
On Wed, Mar 4, 2009 at 12:53 PM, Cristiano Paris fr...@theshire.org wrote: I'd (and indeed I did) write 'update' as: update z x = z { this = this z Just x } exploiting the '' operator's logic. How would this differ from the corresponding 'update' in the original Huet's FP? Maybe I don't get

[Haskell-cafe] Re: Zippers, Random Numbers Terrain

2007-08-06 Thread apfelmus
Thomas Conway wrote: On 8/2/07, apfelmus [EMAIL PROTECTED] wrote: That concludes the infinite terrain generation for one dimension. For higher dimension, one just needs to use 2D objects instead of intervals to split into two or more pieces. For instance, one can divide equilateral triangles

[Haskell-cafe] Re: Zippers, Random Numbers Terrain

2007-08-01 Thread apfelmus
Thomas Conway wrote: This got me thinking that it would be cool to make an infinite terrain generator using a zipper, so you can zoom in/out infinitely, and by implication, infinitely in any direction. After some pondering, I think it's indeed possible and the zipper is the right tool for the

Re: [Haskell-cafe] Re: Zippers, Random Numbers Terrain

2007-08-01 Thread Thomas Conway
On 8/2/07, apfelmus [EMAIL PROTECTED] wrote: That concludes the infinite terrain generation for one dimension. For higher dimension, one just needs to use 2D objects instead of intervals to split into two or more pieces. For instance, one can divide equilateral triangles into 4 smaller ones.

[Haskell-cafe] Re: Zippers, Random Numbers Terrain

2007-08-01 Thread Chung-chieh Shan
Thomas Conway [EMAIL PROTECTED] wrote in article [EMAIL PROTECTED] in gmane.comp.lang.haskell.cafe: On 8/2/07, apfelmus [EMAIL PROTECTED] wrote: That concludes the infinite terrain generation for one dimension. For higher dimension, one just needs to use 2D objects instead of intervals to

[Haskell-cafe] Re: Zippers, Random Numbers Terrain

2007-07-30 Thread apfelmus
Thomas Conway wrote: To amuse myself while waiting for test-runs to complete, I was thinking about random terrain generation. I came across a bunch of nice posts by Torben Mogensen, where he describes a neat way of constructing random terrains by recursively subdividing right angled isosceles

[Haskell-cafe] Re: Zippers, Random Numbers Terrain

2007-07-30 Thread Martin Lütke
apfelmus apfelmus at quantentunnel.de writes: Thomas Conway wrote: To amuse myself while waiting for test-runs to complete, I was thinking about random terrain generation. I came across a bunch of nice posts by Torben Mogensen, where he describes a neat way of constructing random

Re: [Haskell-cafe] Re: Zippers, Random Numbers Terrain

2007-07-30 Thread Jon Harrop
On Monday 30 July 2007 09:51:48 apfelmus wrote: Thomas Conway wrote: To amuse myself while waiting for test-runs to complete, I was thinking about random terrain generation. I came across a bunch of nice posts by Torben Mogensen, where he describes a neat way of constructing random

Re: [Haskell-cafe] Re: Zippers, Random Numbers Terrain

2007-07-30 Thread Dan Piponi
On 7/30/07, Martin Lütke [EMAIL PROTECTED] wrote: It uses a chaotic function (ergodic?) that works on integers. In the case of Terrain it uses 2. One for the x and one for y coordinate. It should be infinite for Zooming out. When zooming in one uses interpolation. The drawback(?) is when