caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Brian Hurt <bhurt@spnz.org>
To: Michael Wohlwend <micha-1@fantasymail.de>
Cc: OCaml Mailing List <caml-list@yquem.inria.fr>
Subject: Re: [Caml-list] algorithm question
Date: Sun, 26 Feb 2006 14:51:40 -0600 (CST)	[thread overview]
Message-ID: <Pine.LNX.4.63.0602261435090.9569@localhost.localdomain> (raw)
In-Reply-To: <200602262121.52645.micha-1@fantasymail.de>



On Sun, 26 Feb 2006, Michael Wohlwend wrote:

>
> I want to implement the dancing link algorithm as described here:
> http://www-cs-faculty.stanford.edu/~knuth/papers/dancing-color.ps.gz
>
> has someone an idea if there is an equally fast way to implent this more
> functional? The method in the paper seems pretty good, just adjusting a the
> linksfields of the structure...

It's solving a problem that doesn't show up in functional programming.

Basically, he's trying to avoid having to duplicate an entire data 
structure in order to preserve a snapshot of the data structure to support 
undoing operations.  With a purely functional (aka applicative aka 
immutable) data structure, modifications are not destructive.  After you 
add a new element into a map, for example, the old map is still valid and 
not changed.  So you can support undoing operations by just keeping 
references to the old copy of the data structure around, and dropping the 
new (modified) data structure and returning to the old one.

Also, he's skating a fine edge.  Operation (2) implicitly assumes that 
L[x] and R[x] have not been modified before the reinsertion happens.  If 
they have been modified, the results depend upon exactly how they've been 
modified, but can easily lead to corrupt data structures.  If you're 
precisely backtracking, it'll be OK, other than that...

Brian


  parent reply	other threads:[~2006-02-26 20:51 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-02-26 20:21 Michael Wohlwend
2006-02-26 20:48 ` [Caml-list] " Diego Olivier Fernandez Pons
2006-02-26 21:28   ` Michael Wohlwend
2006-02-26 20:51 ` Brian Hurt [this message]
2006-02-26 21:03   ` Diego Olivier Fernandez Pons
2006-02-27 10:30   ` Jean-Christophe Filliatre
2006-02-27 11:02     ` Diego Olivier Fernandez Pons
2006-02-27 14:48     ` Brian Hurt

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=Pine.LNX.4.63.0602261435090.9569@localhost.localdomain \
    --to=bhurt@spnz.org \
    --cc=caml-list@yquem.inria.fr \
    --cc=micha-1@fantasymail.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).