
20 Sep
2010
20 Sep
'10
5:05 a.m.
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.