let rec take k a =
  match a with
    | [] -> []
    | h :: t ->
      if k > 0
      then h :: (take (k-1) t)
      else []