Real World Haskell Chapter 2

last []
last [1..]
Haskellで循環リストみたいなものを作れるのならば.
--lastButOne.hs
lastButOne (x:xs) = if length(xs) == 1 then x else lastButOne xs

以下のほうが,関数型ぽいかな?

--lastButOne.hs
lastButOne (x:[_]) = x 
lastButOne (x:xs) = lastButOne xs

lastButTwo (x:[_,_]) = x 
lastButTwo (x:xs) = lastButTwo xs