[Haskell-cafe] another Newbie performance question

Henning Thielemann lemming at henning-thielemann.de
Sun May 18 09:15:10 EDT 2008


On Sat, 17 May 2008, Luke Palmer wrote:

> insertLine line csv = let (l,r) =
>    splitLast csv in l ++ [readCSVLine line] ++ r
>    where
>    splitLast [x]    = ([],[x])
>    splitLast (x:xs) = let (l,r) = splitLast xs in (x:l,r)
>
> (Note that I got rid of the "pos" parameter)

I'd like to have a function like
    Data.List.viewR :: [a] -> Maybe ([a], a)
   analogously to Data.Sequence, which is a safe replacement for 'init' and 
'last'.


More information about the Haskell-Cafe mailing list