Skip to content

Instantly share code, notes, and snippets.

@jacobwalkr
Created October 21, 2014 14:58
Show Gist options
  • Save jacobwalkr/acc2e443f044b73d9ed4 to your computer and use it in GitHub Desktop.
Save jacobwalkr/acc2e443f044b73d9ed4 to your computer and use it in GitHub Desktop.
H-99 problem 2
myLastButOne :: [a] -> a
myLastButOne [] = error "Not enough elements!"
myLastButOne [x] = error "Not enough elements!"
myLastButOne [x,y] = x
myLastButOne (_:xs) = myLastButOne xs
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment