Pascal's triangle: Difference between revisions
Content added Content deleted
(Added Vedit macro language) |
|||
Line 474: | Line 474: | ||
end |
end |
||
</ruby> |
</ruby> |
||
=={{header|Vedit macro language}}== |
|||
===Summing from Previous Rows=== |
|||
{{trans|BASIC}} |
|||
Vedit macro language does not have actual arrays (edit buffers are normally used for storing larger amounts of data). |
|||
However, a numeric register can be used as index to access another numeric register. |
|||
For example, if #99 contains value 2, then #@99 accesses contents of numeric register #2. |
|||
<pre> |
|||
#100 = Get_Num("Number of rows: ", STATLINE) |
|||
#0=0; #1=1 |
|||
Ins_Char(' ', COUNT, #100*3-2) Num_Ins(1) |
|||
for (#99 = 2; #99 <= #100; #99++) { |
|||
Ins_Char(' ', COUNT, (#100-#99)*3) |
|||
#@99 = 0 |
|||
for (#98 = #99; #98 > 0; #98--) { |
|||
#97 = #98-1 |
|||
#@98 += #@97 |
|||
Num_Ins(#@98, COUNT, 6) |
|||
} |
|||
Ins_Newline |
|||
} |
|||
</pre> |
|||
===Using binary coefficients=== |
|||
{{trans|BASIC}} |
|||
<pre> |
|||
#1 = Get_Num("Number of rows: ", STATLINE) |
|||
for (#2 = 0; #2 < #1; #2++) { |
|||
#3 = 1 |
|||
Ins_Char(' ', COUNT, (#1-#2-1)*3) |
|||
for (#4 = 0; #4 <= #2; #4++) { |
|||
Num_Ins(#3, COUNT, 6) |
|||
#3 = #3 * (#2-#4) / (#4+1) |
|||
} |
|||
Ins_Newline |
|||
} |
|||
</pre> |