# draw a Sierpinski triangle

to sierpinski
	to f :x
		if (:x = 0) [ forward 14 stop ]
		f (:x - 1) left  120
		g (:x - 1) right 120
		f (:x - 1) right 120
		g (:x - 1) left  120
		f (:x - 1)
	end

	to g :x
		if (:x = 0) [ forward 14 stop ]
		g (:x - 1)
		g (:x - 1)
	end

	showturtle
	f 4
end