Function: listinsert
Section: programming/specific
C-Name: listinsert0
Prototype: mWGL
Help: listinsert(~L,x,n): insert x at index n in list L, shifting the
 remaining elements to the right.
Description:
 (list, gen, small):gen        listinsert($1, $2, $3)
Doc: inserts the object $x$ at
 position $n$ in $L$ (which must be of type \typ{LIST}).
 This has complexity $O(\#L - n + 1)$: all the
 remaining elements of \var{list} (from position $n+1$ onwards) are shifted
 to the right. If $n$ is greater than the list length, appends $x$.
 \bprog
 ? L = List([1,2,3]);
 ? listput(~L, 4); L \\ listput inserts at end
 %4 = List([1, 2, 3, 4])
 ? listinsert(~L, 5, 1); L \\insert at position 1
 %5 = List([5, 1, 2, 3, 4])
 ? listinsert(~L, 6, 1000); L  \\ trying to insert beyond position #L
 %6 = List([5, 1, 2, 3, 4, 6]) \\ ... inserts at the end
 @eprog\noindent Note the \kbd{\til L}: this means that the function is
 called with a \emph{reference} to \kbd{L} and changes \kbd{L} in place.
