Pascal's triangle: Difference between revisions

add lazy version of pascal
(add lazy version of pascal)
Line 754:
 
say .perl for pascal 10;</lang>
The following routine returns a lazy list of lines using the series operator. With a lazy result you need not tell the routine how many you want; you can just use a slice subscript to get the first N lines:
<lang perl6>sub pascal { [1], -> @p { [0, @p Z+ @p, 0] } ... * }
 
.say for pascal[^10];</lang>
 
=={{header|PHP}}==
<lang php>function pascalsTriangle($num){
Anonymous user