Anonymous user
Sierpinski triangle: Difference between revisions
m
→{{header|REXX}}
(→{{header|J}}: whitespace helps with parsing verbs) |
|||
Line 1,029:
/*REXX program draws a Sierpinksi triangle of any order. */
parse arg m mk .
if m=='' | m==',' then m=4
if length(mk)==2 then mk=x2c(mk) /*MK was specified in hexadecimal*/
numeric digits 2000 /*just in case they want a bigun.*/
call sierpinkski_triangle m /*let's rock 'n roll. */
exit
/*─────────────────────────────────────SIERPINKSKI_TRIANGLE subroutine──*/
sierpinkski_triangle: procedure expose mk; parse arg n .
▲if 1=='f1' then mk='af'x /*if EBCDIC, choose a bullet (∙).*/
▲ do j=0 to n*4-1
!=1
_=left('',n*4-1-j)
say _
end
Line 1,057 ⟶ 1,053:
Output (using the default of order 4):
<pre style="height:40ex;overflow:scroll">
</pre>
Output when using the input of:
<br><br>
8 18
<pre style="height:30ex;overflow:scroll">
▲
Line 1,113 ⟶ 1,109:
Output when using the input of:
<br><br>
32 db
<pre style="height:30ex;overflow:scroll">
█
|