As part of Haskell training, I am trying to implement my own version of various list related functions. Right now I'm stuck in the init function . The init function in Haskell returns all the items in the list other than the last item.
Here is what I have done so far.
init' :: [Int] -> [Int]
init' [] = error "This function cannot be applied to an empty list"
init' [x] = [x]
init' (x:xs) = x : init' xs
source
share