Pascal's triangle: Difference between revisions

→‎{{header|Clojure}}: Added an extra implementation to generate pascal's triangle
(added FunL)
(→‎{{header|Clojure}}: Added an extra implementation to generate pascal's triangle)
Line 531:
(map (partial apply +) ,,,)))
[1]))
</lang>
 
Another short version which returns an infinite pascal triangle as a list, using the iterate function.
 
<lang lisp>
(def pascal
(iterate #(concat [1]
(map + % (rest %))
[1])
[1]))
</lang>
 
One can than get the first nth rows using the take function
 
<lang lisp>
(take 10 pascal) ; returns a list of the first 10 pascal rows
</lang>
 
Also, one can retrieve the nth row using the nth function
 
<lang lisp>
(nth pascal 10) ;returns the nth row
</lang>