Skip to content

Instantly share code, notes, and snippets.

@balajisivaraman
Created October 12, 2014 15:22
Show Gist options
  • Save balajisivaraman/793863922877f0fc5679 to your computer and use it in GitHub Desktop.
Save balajisivaraman/793863922877f0fc5679 to your computer and use it in GitHub Desktop.
Doctest Testing
-- >>> skips "ABCD"
-- ["ABCD","BD","C","D"] -- This passes.
-- >>> skips "ABCD"
-- ["ABCD", "BD", "C", "D"] -- This doesn't pass. I assume because of the whitespace. Why?
-- But both are equal according to GHCi.
skips :: [a] -> [[a]]
skips l = map (getItems l) [1..length l]
where
getItems :: [a] -> Int -> [a]
getItems l n = map (l !!) [n-1,2*n-1..length l - 1]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment