Re: [xsl] RE: Cheaper to prepend or append an item to a sequence?

Subject: Re: [xsl] RE: Cheaper to prepend or append an item to a sequence?
From: Dimitre Novatchev <dnovatchev@xxxxxxxxx>
Date: Tue, 22 Feb 2011 06:36:10 -0800
>> In the functional language Haskell, there is a clear disadvantage of
>> appending an item onto the end of a list, and developers are strongly
>> encouraged to build lists by prepending an item onto a list.
>
> It would be interesting to know the basis for this advice.

The answer is simple: this is the list datatype. A list datatype has
only certain basic operations and all other operations (such as
indexing) have to be expressed in terms of the basic operations.

There are other datatypes in Haskel, such as the one implemented in
the Haskell standard Data.Sequence module, and this implements a
sequence with a finger tree. A finger Tree allows very fast appending,
prepending, inserting and deletion, not slow indexing and can also be
used as a keyed structure .


--
Cheers,
Dimitre Novatchev
---------------------------------------
Truly great madness cannot be achieved without significant intelligence.
---------------------------------------
To invent, you need a good imagination and a pile of junk
-------------------------------------
Never fight an inanimate object
-------------------------------------
You've achieved success in your field when you don't know whether what
you're doing is work or play
-------------------------------------
Facts do not cease to exist because they are ignored.



On Tue, Feb 22, 2011 at 6:24 AM, Michael Kay <mike@xxxxxxxxxxxx> wrote:
>
>> In the functional language Haskell, there is a clear disadvantage of
>> appending an item onto the end of a list, and developers are strongly
>> encouraged to build lists by prepending an item onto a list.
>
> It would be interesting to know the basis for this advice.
>
> (a) Does the Haskell language mandate an implementation?
>
> (b) or is there only one implementation?
>
> (c) or is there so much commonality between implementations that such
advice
> applies to all of them?
>
> (d) or is the book written for users of a particular implementation?
>
> XSLT is more like SQL in this regard - different optimizers do things
> differently.
>
> Michael Kay
> Saxonica

Current Thread