In reply to alx west.

You need *some* additional memory because you are overwriting the positions in the deck. You can get away with allocating half the deck to hold the top (or bottom) cars. You can also reuse the deck storage, if you don't mind losing the original order of the cards.

start PR(deck); /* upon exit, deck contains new order; orig order is gone */
N = ncol(deck); /* send in deck as a row vector */
nT = ceil(N/2); /* cut into two stacks; "Top" gets extra card when N odd */
nB = N - nT; /* nT = size of Top; nB = size of Bottom */
bot = deck[,nT+1:N]; /* store bottom cards in temporary */
deck[, do(1,N,2)] = deck[,1:nT]; /* top cards go into odd positions */
deck[, do(2,N,2)] = bot; /* bottom cards go into even positions */
return(deck);
finish;