DEV Community

loading...

Discussion on: Daily Challenge #124 - Middle Me

Collapse
craigmc08 profile image
Craig McIlwrath

Haskell solution!

middleMe :: Int -> [a] -> a -> [a]
middleMe n x y
  | isOdd n   = x
  | otherwise = let ys = replicate (n `div` 2) y
                in  ys ++ x ++ ys