Replace nulls with preceding non-nulls

fills x     fills[x]

Where x is a list, returns x with any null items replaced by their preceding non-null values, if any.

fills is a uniform function.

q)fills 0N 2 3 0N 0N 7 0N
0N 2 3 3 3 7 7

To back-fill, reverse the list and the result:

q)reverse fills reverse 0N 2 3 0N 0N 7 0N
2 2 3 7 7 7 0N

For a similar function on infinities, first replace them with nulls:

q)fills {(x where x=0W):0N;x} 0N 2 3 0W 0N 7 0W
0N 2 3 3 3 7 7

The keyword fills is defined as ^\, which fills forward, meaning that non-null items are filled over succeeding null items.

q)fills 1 0N 3 0N 0N 5
1 1 3 3 3 5
q)fills `x``y```z
`x`x`y`y`y`z
q)update fills c2 from ([] `a`b`c`d`e`f; c2:1 0N 3 0N 0N 5)
x c2
----
a 1
b 1
c 3
d 3
e 3
f 5

To fill initial nulls apply the derived function as a binary.

q)fills 0N 0N 3 0N 5
0N 0N 3 3 5
q)0 ^\ 0N 0N 3 0N 5
0 0 3 3 5