Pascal's triangle: Difference between revisions

Added RapidQ, added note on BASIC
(added BASIC)
(Added RapidQ, added note on BASIC)
Line 98:
PRINT
NEXT row</freebasic>
 
Note: Unlike most Basic implementations, FreeBASIC requires that all variables have been declared before use
(but this can be changed with compiler options).
 
=={{header|Clojure}}==
Line 390 ⟶ 393:
print " ".join(map(str, last))
return True</python>
 
=={{header|RapidQ}}==
===Summing from Previous Rows===
{{trans|BASIC}}
 
The main difference to BASIC implementation is the output formatting.
RapidQ does not support PRINT USING. Instead, function FORMAT$() is used.
TAB() is not supported, so SPACE$() was used instead.
 
Another difference is that in RapidQ, DIM does not clear array values to zero.
But if dimensioning is done with DEF..., you can give the initial values in curly braces.
If less values are given than there are elements in the array, the remaining positions are initialized to zero.
RapidQ does not require simple variables to be declared before use.
 
<pre>
DEFINT values(100) = {0,1}
 
INPUT "Number of rows: "; nrows
PRINT SPACE$((nrows)*3);" 1"
FOR row = 2 TO nrows
PRINT SPACE$((nrows-row)*3+1);
FOR i = row TO 1 STEP -1
values(i) = values(i) + values(i-1)
PRINT FORMAT$("%5d ", values(i));
NEXT i
PRINT
NEXT row
</pre>
 
===Using binary coefficients===
{{trans|BASIC}}
<pre>
INPUT "Number of rows: "; nrows
FOR row = 0 TO nrows-1
c = 1
PRINT SPACE$((nrows-row)*3);
FOR i = 0 TO row
PRINT FORMAT$("%5d ", c);
c = c * (row - i) / (i+1)
NEXT i
PRINT
NEXT row
</pre>
 
=={{header|Ruby}}==
Anonymous user