Skip to content

Instantly share code, notes, and snippets.

@saesh
Created March 12, 2018 22:05
Show Gist options
  • Select an option

  • Save saesh/7ca7f7ac998fa032bb4025d995810967 to your computer and use it in GitHub Desktop.

Select an option

Save saesh/7ca7f7ac998fa032bb4025d995810967 to your computer and use it in GitHub Desktop.
-- Find the K'th element of a list. The first element in the list is number 1.
elementAt :: [a] -> Int -> a
elementAt list k = (last (take k list))
main :: IO ()
main = print $ elementAt "wikipedia" 5
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment