In recitation/lab this week we will practice with regular expressions and recursion.
This reading is useful to give you some more details and examples and this page provides a summary of regular expressions.
Use this downloadable regex tool to experiment with regular expressions. Complete the questions on the handin page.Snarf the code for this lab or view it online here. It generates a Sierpinski triangle fractal.
The Sierpinski triangle is a fractal because it is a geometric shape that can be split into parts, each of which is (approximately) a reduced-size copy of the whole. In a sense, this is similar to recursion because each successive call to the function works on a reduced copy of the problem. Thus recursion is a natural choice when generating fractal images.
An algorithm for obtaining arbitrarily close approximations to the Sierpinski triangle is as follows:
Complete the function sierpinski
by completing the three recursive calls to generate the pictures above.