If the original list has fewer than k+1 elements, the second list will be empty, and there will be no element to extract.
Note that the Prolog and Lisp versions treat 1 as the first element in the list, and the Lisp version appends NIL elements to the end of the list if k is greater than the list length.

or

removeAt n xs =(xs !!(n -1),take(n -1) xs ++drop n xs)

Another solution that avoids throwing an error and using ++ operators. Treats 1 as the first element in the list.