Task
Produce a graphical or ASCII-art representation of a  Sierpinski arrowhead curve  of at least order  3.




V sqrt3_2 = sqrt(3) / 2
 
F sierpinski_arrowhead_next(points)
   V result = [(0.0, 0.0)] * (3 * (points.len - 1) + 1)
   V j = 0
   L(i) 0 .< points.len - 1
      V (x0, y0) = points[i]
      V (x1, y1) = points[i + 1]
      V dx = x1 - x0
      result[j] = (x0, y0)
      I y0 == y1
         V d = abs(dx * :sqrt3_2 / 2)
         result[j + 1] = (x0 + dx / 4, y0 - d)
         result[j + 2] = (x1 - dx / 4, y0 - d)
      E I y1 < y0
         result[j + 1] = (x1, y0)
         result[j + 2] = (x1 + dx / 2, (y0 + y1) / 2)
      E
         result[j + 1] = (x0 - dx / 2, (y0 + y1) / 2)
         result[j + 2] = (x0, y1)
      j += 3
   result[j] = points.last
   R result
 
V size = 600
V iterations = 8
V outfile = File(‘sierpinski_arrowhead.svg’, ‘w’)
 
outfile.write(‘<svg xmlns='http://www.w3.org/2000/svg' width='’size‘' height='’size"'>\n")
outfile.write("<rect width='100%' height='100%' fill='white'/>\n")
outfile.write(‘<path stroke-width='1' stroke='black' fill='none' d='’)
V margin = 20.0
V side = size - 2 * margin
V x = margin
V y = 0.5 * size + 0.5 * sqrt3_2 * side
V points = [(x, y), (x + side, y)]
L 0 .< iterations
   points = sierpinski_arrowhead_next(points)
L(point) points
   outfile.write(I L.index == 0 {‘M’} E ‘L’)
   outfile.write(point.x‘,’point.y"\n")
outfile.write("'/>\n</svg>\n")