|
Re: Some random newbie questions: msg#00127lang.haskell.cafe
On Sunday 09 January 2005 21:30, Marcin 'Qrczak' Kowalczyk wrote: > Jorge Adriano Aires <jadrian@xxxxxxxxx> writes: > >> No, it would work with strict foldl too. In fact in the absence > >> of optimization it would work better (uses less time and space). > >> The optimization required is inlining and strictness analysis. > > > > Is this also true if your just going to use the first few elements after > > reversing it? > > Yes. A strict fold would evaluate cons cells of the result while they > are constructed, not list elements. They are all defined (flip (:) x y > is always defined), so a strict foldl is correct. Yes, now I was refering to the efficiency issue only. > Making a cons cell should be not more expensive than making a thunk > which will make a cons cell when evaluated. Ok, I wasn't sure about this... > Well, unless the > implementation doesn't inline flip and thus making these thunks > is actually faster than running them. In this case a lazy foldl is > more efficient than a strict foldl, as long as a sufficiently small > part of the result is used; it's always less efficient if the whole > result is examined. Right. J.A. |
|
| <Prev in Thread] | Current Thread | [Next in Thread> |
|---|---|---|
| Previous by Date: | Re: Some random newbie questions: 00127, Marcin 'Qrczak' Kowalczyk |
|---|---|
| Next by Date: | Re: Some random newbie questions: 00127, Jorge Adriano Aires |
| Previous by Thread: | Re: Some random newbie questionsi: 00127, Marcin 'Qrczak' Kowalczyk |
| Next by Thread: | Re: Some random newbie questions: 00127, Jorge Adriano Aires |
| Indexes: | [Date] [Thread] [Top] [All Lists] |
| News | FAQ | advertise |