There is a well known fractal shape called the Koch snowflake:
The code for this is in two functions, one to draw a side of the snowflake and the other to draw the whole snowflake.
TO SIDE :LENGTH
IF :LENGTH < 2 [FD :LENGTH STOP]
SIDE :LENGTH / 3 LT 60
SIDE :LENGTH / 3 RT 120
SIDE :LENGTH / 3 LT 60
SIDE :LENGTH / 3
END
TO SNOWFLAKE :LEN
SIDE :LEN RT 120
SNOWFLAKE :LEN
END

Enter something like SNOWFLAKE 100 to draw your first snowflake. You might like to try drawing multiple snowflakes with ACTIVATEALL and EACH which you learned earlier.
By using SETZOOM 2 we can get a better impression of what is going on in the procedures and how the shape is produced.

We start with a simple hexagon and then change each edge so that there is a protrusion on each side:

We then repeat this process on each side of the new shape:

We can see this better if we edit the SIDE function to set the limit to a higher level such as 30 (the function STOPs when the length of each side is reduced to less than 30):

And then repeat this with the limit of the sides reduced to 10:

Better still, we can change the code of both functions to include a LIMIT parameter so that we can decide when we draw a shape just what level of detail we will include:
TO SIDE :LENGTH :LIMIT
IF :LEN < :LIMIT [FD :LENGTH STOP]
SIDE :LENGTH / 3 :LIMIT LT 60
SIDE :LENGTH / 3 :LIMIT RT 120
SIDE :LENGTH / 3 :LIMIT LT 60
SIDE :LENGTH / 3 :LIMIT
END
TO SNOWFLAKE :LENGTH :LIMIT
SIDE :LENGTH :LIMIT RT 120
SNOWFLAKE :LENGTH :LIMIT
END
And so, finally, to an explanation of the functions. The SNOWFLAKE function calls SIDE, turns the turtle 120 degrees and then calls SNOWFLAKE again. The SIDE function draws each side of the shape but only when the length has been reduced to something less than the LIMIT. Each section of the snowflake has four sides and there are four corresponding calls to the SIDE function. Only the first three require the turtle to be turned after drawing. Only when SIDE has been called to the stopping point (when LENGTH is less than LIMIT) is the turtle moved forward and turned.
The calls to SIDE are recursive and the first calls, with LENGTH set to, say, 100, are left to run off later. The sequence is something like this:
SNOWFLAKE calls SIDE with 100 for LENGTH and 20 for LIMIT
SIDE 100 20 (100 > 20 so no drawing takes place)
SIDE 33.3 20 (33.3 > 20 so no drawing takes place)
SIDE 11.1 20 (11.1 < 20 so turtle is moved
11.1 & turned 60 degrees left
SIDE closes without drawing
SIDE closes without drawing
SIDE 100 20 (100 > 20 so no drawing takes place)
SIDE 33.3 20 (33.3 > 20 so no drawing takes place)
SIDE 11.1 20 (11.1 < 20 so the turtle is moved 11.1 & turned 60 degrees left
SIDE closes without drawing
SIDE closes without drawingwithout SIDE 100 20 (100 > 20 so no drawing takes place)
SIDE 33.3 20 (33.3 > 20 so no drawing takes place)
SIDE 11.1 20 (11.1 < 20 so turtle is moved 11.1 & turned 120 degrees right
SIDE closes without drawing
SIDE closes without drawingwithout SIDE 100 20 (100 > 20 so no drawing takes place)
SIDE 33.3 20 (33.3 > 20 so no drawing takes place)
SIDE 11.1 20 (11.1 < 20 so the turtle is moved 11.1)
SIDE closes without drawing
SIDE closes without drawing and returns to SNOWFLAKE
SNOWFLAKE turns the turtle 120 degrees and calls SIDE again to draw another series of lines.
SNOWFLAKE calls itself and draws the snowflake for ever. ake for ever.
The Koch snowflake is an example of a fractal shape, that is one which is has the same shape at different scales. No matter what scale you view the Koch snowflake the shape is always the same and this continues to very small lengths. The Logo screen cannot reveal what happens when the length of a side falls below 1, though you can use SETZOOM to enlarge small scale dA better program for viewing fractals is FractInt which allows you to select a small part of a fractal image and to enlarge this area, and to repeat this process many times over. The fractals supplied with FractInt include the now famous Mandelbrot formula which some consider to be the most complex object in Mathematics. Investigations of this nature have only become possible with the development of high speed and graphical computers - Mandelbrot himslef worked for IBM when he 'discovered' the 'set' in the 1960s. Mandelbrot went on to write a book called 'The Fractal Geometry of Nature' in which he points out many naturally occurring fractals in objects such as clouds, trees, river basins, veins and the of the lungs.
Here is a rotation of the basic shape to make our first attempt at a snowflake:
TO CRYSTAL :L
FD :L LT 60 FD :L*3 BK :L*3 RT 120 FD :L*3 BK :L *3 LT 60
FD :L LT 60 FD :L*2 BK :L*2 RT 120 FD :L*2 BK :L*2 LT 60
FD :L LT 60 FD :L BK :L RT 120 FD :L BK :L LT 60
BK :L BK :L BK :L
END
REPEAT 6[CRYSTAL 10 LT 60]

The basic shape is simple but a reasonable starting point. When drawn six times through 360 degrees, however, it is not very successful as a snowflake so let us try to amend it. We can try replacing the * operator with +. You can see that this gives us a better flake so now we can try changing the numbers:
TO CRYSTAL :L
FD :L
LT 60 FD :L BK :L RT 120 FD :L BK :L LT 60
FD :L
LT 60 FD :L-10 BK :L-10 RT 120
FD :L-10 BK :L-10 LT 60
FD :L
LT 60 FD :L-20 BK :L-20 RT 120
FD :L-20 BK :L-20 LT 60
BK :L BK :L BK :L
END

We can now increase the intricacy of the design so it has something of the complexity of a real snowflake.
TO CRYSTAL :L
REPEAT 6[BRANCH :L HOME LT 60]
END
TO BRANCH :L
IF :L < 5 [STOP]
FD :L/3
LT 60
FD :L/3 LT 60
FD :L/4 BK :L/4
RT 120
FD :L/4 BK :L/4
LT 60
FD :L /4 BK :L /4
BK :L /3
RT 120
FD :L/3 LT 60
FD :L/4 BK :L/4
RT 120
FD :L/4 BK :L/4
LT 60
FD :L /4 BK :L /4
BK :L/3
LT 60
BRANCH :L/1.5
END
CRYSTAL 50

Study this code carefully and see if you can come up with alternative forms for the basic branch of the snowflake. The recursion of the earlier TREE function has been merged with the early snowflake designs to produce more compact code for a complex form. Notice the need to counter the reverse of each FORWARD movement with a corresponding BACK movement, and to reverse each turn to the LEFT with a corresponding turn to the RIGHT.
Here are some real snowflakes on which you could base further designs:
