[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: RE: Cheaper to prepend or append an item to a seq

Subject: Re: 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
Re:  RE: Cheaper to prepend or append an item to a  seq
>> 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

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.