DEV Community

loading...

Discussion on: Daily Challenge #1 - String Peeler

Collapse
craigmc08 profile image
Craig McIlwrath

Haskell:

removeFirstAndLast :: [a] -> Maybe [a]
removeFirstAndLast xs 
  | length xs < 3 = Nothing 
  | otherwise = Just $ init $ tail xs

As a bonus, it works on any type of list

Forem Open with the Forem app