8. Pascal’s Triangle
P ← ↑ {(0∘,+,∘0)⍣⍵,1}¨∘⍳
Pascal’s triangle
[32].
P 10
1 0 0 0 0 0 0 0 0 0
1 1 0 0 0 0 0 0 0 0
1 2 1 0 0 0 0 0 0 0
1 3 3 1 0 0 0 0 0 0
1 4 6 4 1 0 0 0 0 0
1 5 10 10 5 1 0 0 0 0
1 6 15 20 15 6 1 0 0 0
1 7 21 35 35 21 7 1 0 0
1 8 28 56 70 56 28 8 1 0
1 9 36 84 126 126 84 36 9 1
10 ↑ (,∘.+⍨⍳10) {+/⍵}⌸ ,P 10
1 1 2 3 5 8 13 21 34 55
The expression (0,x)+(x,0) or its commute,
which generates the next set of binomial coefficients, is present
in the document that introduced APL\360 in 1967
[33]
and the one that introduced J in 1990
[34a];
in Elementary Functions: An Algorithmic Treatment in 1966
[35],
in APL\360 User’s Manual in 1968
[36],
in Algebra: An Algorithmic Treatment in 1972
[37],
in Introducing APL to Teachers in 1972
[38],
in An Introduction to APL for Scientists and Engineers in 1973
[39],
in Elementary Analysis in 1976
[40],
in Programming Style in APL in 1978
[41],
in Notation as a Tool of Thought in 1980
[3a],
in A Dictionary of APL in 1987
[42a].
∘.!⍨⍳n also computes Pascal’s triangle of order n .
It is shorter, but is less interesting algorithmically and historically.
|