Anonymous user
Pascal's triangle: Difference between revisions
m
→{{header|Common Lisp}}
Line 1,143:
(cons (+ (car l) (cadr l)) (newrow (cdr l)))))</lang>
An iterative solution with ''loop'', using ''nconc'' instead of ''collect'' to keep track of the last ''cons''. Otherwise, it would be necessary to traverse the list to do a ''(rplacd (last a) (list 1))''
<lang lisp>(defun pascal-next-row (a)
|