Task

Draw a Cantor set.



See details at this Wikipedia webpage:   Cantor set

proc Cantor(N, LineSeg, Len);   \Delete middle third of LineSeg
int  N; char LineSeg; int Len, Third, I;
[if N>0 and Len>1 then
    [Third:= Len/3;
    for I:= Third, 2*Third-1 do LineSeg(I):= ^ ;
    Cantor(N-1, LineSeg, Third);
    Cantor(N-1, LineSeg+2*Third, Third);
    ];
];
 
char LineSeg, N;
[LineSeg:=
"#################################################################################
";
for N:= 0 to 4 do
    [Cantor(N, LineSeg, 81);
    Text(0, LineSeg);
    ];
]