On Sat, 2009-01-17 at 10:44 -0800, Max Rabkin wrote:

> This traverses the list three times (reverse, init and last are each
> linear time):
> fromListEnd xs = Zipper (reverse $ init xs) (last xs) []
> 
> But we only need to do it once:
> fromListEnd xs = let x:xs' = reverse xs in Zipper xs' x []
> 
> I don't *think* this has an effect on strictness/laziness, since both
> versions are strict in the spine of the list.

Excellent suggestion; your solution is much more readable and faster.

I've made the change here: http://hpaste.org/14030#a1

Thanks,

Jeff Wheeler

_______________________________________________
Haskell mailing list
Haskell@haskell.org
http://www.haskell.org/mailman/listinfo/haskell

Reply via email to