summaryrefslogblamecommitdiff
path: root/1-10/3.hs
blob: 660ae64aaca82fe43f5bfd9b6f0e3d9b31ed1ba2 (plain) (tree)
1
2
3
4
5




                                                                   
elementAt [] _ = error "out of range"
elementAt (x:_) 1 = x
elementAt (_:xs) k
  | k < 1     = error "out of range" -- deal with the infinite list
  | otherwise = elementAt xs (k - 1)