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
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 intuition.
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
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
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?
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
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
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 then appending should