Let's show an example of fractal to clarify. The koch snowflake can be obtained by dividing a line in 3 equal segments and replacing the middle one with an equilateral triangle, with side 1/3 of the line, and removing the lower side of the triangle.
This process can then be reused on all segments obtained from the last iteration an indefinite number of times. The following image shows the first 5 iteration of Koch's snowflake. It should now be fairly clear what a fractal is.
\usepackage{tikz}
\usetikzlibrary{lindenmayersystems}
We first need to define such a curve (inside the document).
\pgfdeclarelindenmayersystem{Koch}
{\rule {F -> F+F--F+F}}
Now that the function is defined we can make the fractal. In this step is also necessary to define the lenght of a step, the angle, the order (the iteration that has to be depicted) and an axiom.
\begin{tikzpicture}
\draw
[l-system={Koch curve, step=2pt, angle=60, axiom=F, order=4}]
lindenmayer system;
\end{tikzpicture}
To clarify let's make a couple of example. In the first one I will set the axiom to F++F++F, this will make our starting figure an equilateral rectangle instead of a line, and the fractal will be developed internally.
\begin{tikzpicture}
\draw
[l-system={Koch curve, step=2pt, angle=60, axiom=F++F++F, order=4}]
lindenmayer system;
\end{tikzpicture}
\begin{tikzpicture}
\draw
[l-system={Koch curve, step=2pt, angle=60, axiom=F--F--F, order=4}]
lindenmayer system;
\end{tikzpicture}
Let's start with one of my favourites, Sierpinki's triangle, at the eight iteration.
\pgfdeclarelindenmayersystem{Sierpinski triangle}{
\rule{F -> G-F-G}
\rule{G -> F+G+F}}
\begin{tikzpicture}
\draw
[l-system={Sierpinski triangle, step=2pt, angle=60, axiom=F, order=6}]
lindenmayer system -- cycle;
\end{tikzpicture}
\pgfdeclarelindenmayersystem{Hilbert curve}{
\rule{L -> +RF-LFL-FR+}
\rule{R -> -LF+RFR+FL-}}
\begin{tikzpicture}
\draw [bottom color=blue, top color=blue]
[l-system={Hilbert curve, axiom=L, order=5, step=8pt, angle=90}]
lindenmayer system;
\end{tikzpicture}
To test if all these new concepts have been understood I would invite the
reader to try and replicate the following fractal. Hint, it is fairly
similar to Koch's snowflake.
And if you hate yourself you can also try to reproduce the
Mandelbrot set in Latex.
\pgfdeclarelindenmayersystem{fractal}{
\rule{F -> F+F-F-F+F }}
\begin{tikzpicture}
\draw
[l-system={fractal, step=2pt, angle=90, axiom=F, order=4}]
lindenmayer system;
\end{tikzpicture}