Tikz Fractal - Cantor Dust

It is a nice Lindenmayer system exercise.

\documentclass[border=9,tikz]{standalone}
\usetikzlibrary{lindenmayersystems}
\begin{document}
\pgfdeclarelindenmayersystem{Cantor dust}{
    \symbol{S}{\pgfpathrectangle{\pgfpointorigin}{\pgfpoint{\pgflsystemcurrentstep}{\pgflsystemcurrentstep}}}
    \symbol{U}{\pgftransformyshift{\pgflsystemcurrentstep}}
    \symbol{R}{\pgftransformxshift{\pgflsystemcurrentstep}}
    \rule{S -> [UUSURRS][RSRRUS]}
    \rule{U -> UUUU}
    \rule{R -> RRRR}
}
\tikz;
\tikz\fill[lindenmayer system={Cantor dust,axiom=S,step=320pt,order=1}]lindenmayer system;
\tikz\fill[lindenmayer system={Cantor dust,axiom=S,step= 80pt,order=2}]lindenmayer system;
\tikz\fill[lindenmayer system={Cantor dust,axiom=S,step= 20pt,order=3}]lindenmayer system;
\tikz\fill[lindenmayer system={Cantor dust,axiom=S,step=  5pt,order=4}]lindenmayer system;
\end{document}


I've just discovered this topic, which was related to another, more recent one. It can be considered as an application of recursive programming, for which MetaPost is usually well suited. So here is a MetaPost solution, for whom it may interest.

def cantor_dust(expr x, y, d, n) = 
    if n > 0:
        cantor_dust(x+.25d, y, .25d, n-1);
        cantor_dust(x+.75d, y+.25d, .25d, n-1);
        cantor_dust(x+.5d, y+.75d, .25d, n-1);
        cantor_dust(x, y+.5d, .25d,  n-1);
    else: fill (x, y) -- (x+d, y) -- (x+d, y+d) -- (x, y+d) -- cycle; fi
enddef;
beginfig(1);
    for i = 0 upto 4:
        draw image(cantor_dust(0, 0, 4cm, i)) shifted (4.25cm*i, 0);
    endfor;
endfig;
end.

enter image description here