module ListUtils where


-- | create a singleton list, you can also use 'return' for the list 'Monad'
singleton :: a -> [a]
singleton x = [x]


-- | apply a function to the @n@th element of a list
onNth :: Int -> (a -> a) -> [a] -> [a]
onNth n f xs =
   let (ys,zs) = splitAt n xs
   in  ys ++
         case zs of
            []    -> []
            z:zs' -> f z : zs'