Pascal's triangle: Difference between revisions

no edit summary
(added Fortran)
No edit summary
Line 47:
end Pascals_Triangle;
</ada>
 
=={{header|Common Lisp}}==
To evaluate, call (pascal n). For n < 1, it simply returns nil.
 
<lisp>(defun pascal (n)
(genrow n '(1)))
 
(defun genrow (n l)
(if (< 0 n)
(progn
(print l)
(genrow (- n 1) (cons 1 (newrow l))))))
 
(defun newrow (l)
(if (> 2 (length l))
'(1)
(cons (+ (car l) (cadr l)) (newrow (cdr l)))))</lisp>
 
=={{header|D}}==
There is similarity between Pascal's triangle and [[Sierpinski triangle]]. Their difference are the initial line and the operation that act on the line element to produce next line. The following is a generic pascal's triangle implementation for positive number of lines output (n).