Send Beginners mailing list submissions to
[email protected]
To subscribe or unsubscribe via the World Wide Web, visit
http://www.haskell.org/mailman/listinfo/beginners
or, via email, send a message with subject or body 'help' to
[email protected]
You can reach the person managing the list at
[email protected]
When replying, please edit your Subject line so it is more specific
than "Re: Contents of Beginners digest..."
Today's Topics:
1. Re: More than one way to skin a cat question - repeat (Tom Davie)
----------------------------------------------------------------------
Message: 1
Date: Thu, 11 Apr 2013 10:53:03 +0100
From: Tom Davie <[email protected]>
Subject: Re: [Haskell-beginners] More than one way to skin a cat
question - repeat
To: The Haskell-Beginners Mailing List - Discussion of primarily
beginner-level topics related to Haskell <[email protected]>
Message-ID: <[email protected]>
Content-Type: text/plain; charset="iso-8859-1"
On 11 Apr 2013, at 10:47, Benjamin Edwards <[email protected]> wrote:
> (:) is O(1), (++) is O(n). Try and implement (++) and it should be easy to
> see why.
>
(++) is O(n) in the length of it's first argument, which here is a constant 1,
so it's O(1).
That said, the book's implementation is *margionally* better. The
implementation using (++) creates the list [x], and then destroys it again, and
creates another one when it does the append. The version using (:) does not do
this.
Thanks
Tom Davie
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
<http://www.haskell.org/pipermail/beginners/attachments/20130411/de6048d1/attachment-0001.htm>
------------------------------
_______________________________________________
Beginners mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/beginners
End of Beginners Digest, Vol 58, Issue 23
*****************************************