Jim Callahan says:
> It seems that there is no way to update even the smallest part of the
> data-structure without having to traverse the entire thing. This seems to be
> an inherent property of purely functional languages. This might not be a
> big deal with linked lists but consider something much larger and mode complex
> like a cyclic graph, etc...
> ...
> Am I missing something fundamental here? I sure hope so...
No, you're not missing anything. That's how it is.
> In SML, I'd just cheat and use "ref"'s internally but provide a functional
> interface to the user.
I wouldn't call it "cheating". It's just different, with different
properties. For many applications, some might say that this is the
more "natural" way of expressing things.
On the other hand, for other applications, the purely functional style
may be considered better-- it admits more parallelism. For example,
suppose you had a concurrent process that is still working on the old
graph (e.g., analysing it, or backing it up to permananent store, or
whatever). Then, the purely functional version allows you to
construct and work with the new graph while that other activity is
still under way; the "ref" version will make you wait until that
activity is complete before you can modify the graph.
Nikhil
----------------------------------------------------------------
Rishiyur S. Nikhil
email (nom de qwerty): <[EMAIL PROTECTED]> <[EMAIL PROTECTED]> <[EMAIL PROTECTED]>
telephone: +1 (617) 692 7639 fax : +1 (617) 692 7650
url: http://www.research.digital.com/CRL/personal/nikhil
address: Digital Equipment Corporation,
Cambridge Research Laboratory,
One Kendall Square, Bldg. 700, Cambridge, MA 02139, USA
----------------------------------------------------------------