Skip to content

Instantly share code, notes, and snippets.

@lwiechec
Created November 4, 2014 22:45
Show Gist options
  • Save lwiechec/50904e98eacab1e6820c to your computer and use it in GitHub Desktop.
Save lwiechec/50904e98eacab1e6820c to your computer and use it in GitHub Desktop.
double every second element of the list
--
-- I didn't check the exercise, can we use take, double and drop?
--
double :: Num a => [a] -> [a]
double [] = []
double (x:xs) = [2*x] ++ take 1 xs ++ double (drop 1 xs)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment