Task

Draw a Cantor set.



See details at this Wikipedia webpage:   Cantor set

V WIDTH = 81
V HEIGHT = 5
 
F cantor(start, len, index)
   V seg = len I/ 3
   I seg == 0
      R
   L(it) 0 .< :HEIGHT - index
      V i = index + it
      L(jt) 0 .< seg
         V j = start + seg + jt
         V pos = i * :WIDTH + j
         :lines[pos] = ‘ ’
   cantor(start, seg, index + 1)
   cantor(start + seg * 2, seg, index + 1)
 
V lines = [‘*’] * (WIDTH * HEIGHT)
cantor(0, WIDTH, 1)
 
L(i) 0 .< HEIGHT
   V beg = WIDTH * i
   print((lines[beg .< beg + WIDTH]).join(‘’))