Skip to content

Instantly share code, notes, and snippets.

@GetContented
Last active July 16, 2016 09:37
Show Gist options
  • Save GetContented/733a4fdd837c8058fe6f8ac1e3c5e36a to your computer and use it in GitHub Desktop.
Save GetContented/733a4fdd837c8058fe6f8ac1e3c5e36a to your computer and use it in GitHub Desktop.
elementAt :: Integral b => [a] -> b -> Maybe a
elementAt (x:_) 1 = Just x
elementAt (_:xs) k = elementAt xs (k - 1)
elementAt _ _ = Nothing
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment