Luke Palmer schrieb:
> I think this is O(n) time, O(1) space (!).
> 
> lastk :: Int -> [a] -> [a]
> lastk k xs = last $ zipWith const (properTails xs) (drop k xs)
>     where properTails = tail . tails

If (drop k xs) is empty, this yields an error when calling 'last'. This
might be a bug or a feature.
_______________________________________________
Haskell-Cafe mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/haskell-cafe

Reply via email to