Produce a graphical or ASCII-art representation of a Sierpinski pentagon (aka a Pentaflake) of order 5. Your code should also be able to correctly generate representations of lower orders: 1 to 4.





See also
 Sierpinski pentagon


[ $ "turtleduck.qky" loadfile ] now!
 
[ [ 1 1 
    30 times 
       [ tuck + ] 
   swap join ] constant 
   do ]                 is phi        (       --> n/d )
 
[ 5 times
    [ 2dup walk
      1 5 turn ] 
  2drop ]               is pentagon   ( n/d n -->     )
 
                forward is pentaflake
 
[ dup 0 = iff 
    [ drop  
      ' [ 79 126 229 ] fill
      pentagon ] done
  1 - temp put
  5 times
    [ 2dup 2 1 phi v- v*
      temp share pentaflake
      2dup fly
    1 5 turn ]
  temp release 
  2drop ]         resolves pentaflake ( n/d n -->     )
 
turtle
3 10 turn
300 1 fly
2 5 turn
' [ 79 126 229 ] colour
400 1 5 pentaflake