Pascal's triangle: Difference between revisions
Content added Content deleted
(→{{header|Common Lisp}}: improve the second version: naming, don't compute the length of a row) |
|||
Line 4,590: | Line 4,590: | ||
1 7 21 35 35 21 7 1 |
1 7 21 35 35 21 7 1 |
||
1 8 28 56 70 56 28 8 1 |
1 8 28 56 70 56 28 8 1 |
||
=={{header|Picat}}== |
|||
<lang Picat></lang> |
|||
spatr([]) = []. |
|||
spatr([_|T]) = A, T = [] => A = []. |
|||
spatr([H|T]) = A, T = [TH|_] => A = [H+TH] ++ spatr(T). |
|||
table |
|||
patr(0) = [1]. |
|||
patr(1) = [1, 1]. |
|||
patr(N) = A, N > 1 => Apre = patr(N-1), A = [1] ++ spatr(Apre) ++ [1]. |
|||
foreach(I in 0 .. 10) println(patr(I)) end. |
|||
[1] |
|||
[1,1] |
|||
[1,2,1] |
|||
[1,3,3,1] |
|||
[1,4,6,4,1] |
|||
[1,5,10,10,5,1] |
|||
[1,6,15,20,15,6,1] |
|||
[1,7,21,35,35,21,7,1] |
|||
[1,8,28,56,70,56,28,8,1] |
|||
[1,9,36,84,126,126,84,36,9,1] |
|||
[1,10,45,120,210,252,210,120,45,10,1] |
|||
=={{header|PicoLisp}}== |
=={{header|PicoLisp}}== |