Pascal's triangle: Difference between revisions

Line 266:
</lang>
The ''assert'' form causes the ''pascal'' function to throw an exception unless the argument is (integral and) positive.
 
Here's a third version using the ''iterate'' function
<lang lisp>
(def pascal
(iterate
(fn [prev-row]
(->>
(concat [[(first prev-row)]] (partition 2 1 prev-row) [[(last prev-row)]])
(map (partial apply +) ,,,)))))
</lang>
 
=={{header|Common Lisp}}==
Anonymous user