Cantor set: Difference between revisions
Content deleted Content added
Added solution for Action! |
|||
Line 2,490:
*** *** *** *** *** *** *** ***
* * * * * * * * * * * * * * * *</pre>
=={{header|Objeck}}==
{{trans|Java}}
<lang objeck>class CantorSet {
WIDTH : static : Int;
HEIGHT : static : Int;
lines : static : Char[,];
function : Init() ~ Nil {
WIDTH := 81;
HEIGHT := 5;
lines := Char->New[HEIGHT, WIDTH];
each(i : HEIGHT) {
each(j : WIDTH) {
lines[i,j] := '*';
};
};
}
function : Cantor(start : Int, len : Int, index : Int) ~ Nil {
seg : Int := len / 3;
if(seg = 0) {
return;
};
for(i := index; i < HEIGHT; i += 1;) {
for(j := start + seg; j < start + seg * 2; j += 1;) {
lines[i,j] := ' ';
};
};
Cantor(start, seg, index + 1);
Cantor(start + seg * 2, seg, index + 1);
}
function : Main(args : String[]) ~ Nil {
Init();
Cantor(0, WIDTH, 1);
each(i : HEIGHT) {
each(j : WIDTH) {
lines[i,j]->Print();
};
""->PrintLine();
};
}
}</lang>
{{Output}}
<pre>
*********************************************************************************
*************************** ***************************
********* ********* ********* *********
*** *** *** *** *** *** *** ***
* * * * * * * * * * * * * * * *
</pre>
=={{header|Perl}}==
|