DEV Community

Discussion on: Daily Challenge #25 - Double Cola

Collapse
 
avalander profile image
Avalander

Naïve implementation in Haskell.

who_is_next :: [String] -> Int -> String
who_is_next names i
  | length names >= i = names!!(i - 1)
  | otherwise         = who_is_next new_names (i - 1)
  where
    (x:rest) = names
    new_names = rest ++ [x, x]