Re: [Haskell-cafe] appending an element to a list

2008-06-11 Thread Derek Elkins
On Wed, 2008-06-11 at 17:18 -0700, Evan Laforge wrote: > > Lets look at the actual reductions going on. To make the example easier, > > I would like to use last instead of your complicated until. It shouldn't > > make a difference. > > [ winds up doing twice as much work ] > > This was also my in

Re: [Haskell-cafe] appending an element to a list

2008-06-11 Thread Evan Laforge
> Lets look at the actual reductions going on. To make the example easier, > I would like to use last instead of your complicated until. It shouldn't > make a difference. [ winds up doing twice as much work ] This was also my intuition. I had a function that built up a large output list by gener

Re: [Haskell-cafe] appending an element to a list

2008-05-30 Thread Tillmann Rendel
Lanny Ripple wrote: My $0.02 is to say -- O(1) longList ++ [5] Yay. I've got a thunk. Oh wait, I need to access the '5'? No different than doing so for -- O(n) until ((==5) . head) [l,o,n,g,L,i,s,t,5] It's not the (++) that's O(n). It's the list traversal. Lets look at the actual redu

Re: [Haskell-cafe] appending an element to a list

2008-05-30 Thread Lanny Ripple
My $0.02 is to say -- O(1) longList ++ [5] Yay. I've got a thunk. Oh wait, I need to access the '5'? No different than doing so for -- O(n) until ((==5) . head) [l,o,n,g,L,i,s,t,5] It's not the (++) that's O(n). It's the list traversal. I can further beat this pedantic point to dea

Re: [Haskell-cafe] appending an element to a list

2008-05-29 Thread Abhay Parvate
On Thu, May 29, 2008 at 11:48 PM, Tillmann Rendel <[EMAIL PROTECTED]> wrote: > > > Adrian Neumann wrote: > >> Hello, >> >> I was wondering how expensive appending something to a list really is. Say >> I write >> >> I'd say "longList ++ [5]" stays unevaluated until I consumed the whole >> list and

Re: [Haskell-cafe] appending an element to a list

2008-05-29 Thread Tillmann Rendel
Adrian Neumann wrote: Hello, I was wondering how expensive appending something to a list really is. Say I write I'd say "longList ++ [5]" stays unevaluated until I consumed the whole list and then appending should go in O(1). Similarly when concatenating two lists. Is that true, or am I

Re: [Haskell-cafe] appending an element to a list

2008-05-29 Thread Joachim Breitner
Hi, Am Donnerstag, den 29.05.2008, 19:04 +0200 schrieb Adrian Neumann: > I was wondering how expensive appending something to a list really is. > Say I write > > I'd say "longList ++ [5]" stays unevaluated until I consumed the whole > list and then appending should go in O(1). Similarly when co

[Haskell-cafe] appending an element to a list

2008-05-29 Thread Adrian Neumann
Hello, I was wondering how expensive appending something to a list really is. Say I write I'd say "longList ++ [5]" stays unevaluated until I consumed the whole list and then appending should go in O(1). Similarly when concatenating two lists. Is that true, or am I missing something? Adri