Nearby items in a list

x xprev y     xprev[x;y]

Where x is a long atom and y is a list, returns for each item of y the item x indices before it.

The first x items of the result are null, empty or blank as appropriate.

There is no xnext function.

Fortunately xprev with a negative number on the left can achieve this.

q)2 xprev 2 7 5 3 11
0N 0N 2 7 5
q)-2 xprev 2 7 5 3 11
5 3 11 0N 0N
q)1 xprev "abcde"
" abcd"

xprev is a right-uniform function.