How to return the first n-1 elements of a list of length n in Haskell?

advertisements

I know about the tail function that returns the last n-1 elements of a list (where n is the length of the list), so I defined my own "cotail" function to return the first n-1 elements:

cotail = (reverse . tail . reverse)

Is this the best way, or is there a builtin function or a cleverer way to achieve this?


I believe you're looking for init.