All pastes #1402463 Raw Edit

Mine

public text v1 · immutable
#1402463 ·published 2009-04-25 01:48 UTC
rendered paste body
-- Write a function, lastButOne, that returns the element before the last.
lastButOne :: [a] -> [a]
lastButOne xs = if null xs 
                then xs
                else head (drop ((length xs) - 2) xs)