We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
Each triangle with h=4 on the last picture has been submitted by the identical 3 other triangles with half hight (h'=h/2) and less level of recursion (r'=r-1) from the first picture.
Functions and Fractals: Sierpinski triangles
You are viewing a single comment's thread. Return to all comments →
This problem is about recursion and functional programming.
Let's discover recursion pattern. The first figure:
r = 1 (recursion level)
h = 4 (hight of the figure)
The second figure:
r = 2
h = 8
Each triangle with h=4 on the last picture has been submitted by the identical 3 other triangles with half hight (h'=h/2) and less level of recursion (r'=r-1) from the first picture.
Thus, recursion function looks like
where
and
The transpose(arr), rectangle(h), line(h) functions will help to solve this problem with no val or var :)