You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

10 lines
335 B

{-# LANGUAGE StandaloneDeriving #-}
{-# OPTIONS_GHC -Wno-orphans #-}
-- Find the K'th element of a list. The first element in the list is number 1
-- !!: accepts a list and an integer and returns the item in the list at integer
-- position. The numbering starts with 0.
elementAt :: [a] -> Int -> a
elementAt list i = list !! (i-1)